@microsoft/omnichannel-chat-widget 0.1.0-main.47ede4d → 0.1.0-main.5854782

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 (138) hide show
  1. package/README.md +32 -0
  2. package/lib/cjs/common/Constants.js +50 -6
  3. package/lib/cjs/common/telemetry/TelemetryConstants.js +38 -3
  4. package/lib/cjs/common/telemetry/TelemetryHelper.js +13 -0
  5. package/lib/cjs/common/telemetry/TelemetryManager.js +10 -1
  6. package/lib/cjs/common/telemetry/defaultConfigs/defaultTelemetryConfiguration.js +4 -1
  7. package/lib/cjs/common/telemetry/loggers/ariaTelemetryLogger.js +33 -13
  8. package/lib/cjs/common/telemetry/loggers/consoleLogger.js +6 -5
  9. package/lib/cjs/common/utils.js +89 -2
  10. package/lib/cjs/components/callingcontainerstateful/CallingContainerStateful.js +14 -0
  11. package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +20 -4
  12. package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +4 -40
  13. package/lib/cjs/components/footerstateful/FooterStateful.js +1 -2
  14. package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +11 -2
  15. package/lib/cjs/components/headerstateful/HeaderStateful.js +5 -10
  16. package/lib/cjs/components/livechatwidget/common/ActivityStreamHandler.js +44 -0
  17. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js +23 -0
  18. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/IActivitySubscriber.js +1 -0
  19. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js +39 -0
  20. package/lib/cjs/components/livechatwidget/common/ChatAdapterShim.js +70 -0
  21. package/lib/cjs/components/livechatwidget/common/Deferred.js +42 -0
  22. package/lib/cjs/components/livechatwidget/common/authHelper.js +52 -0
  23. package/lib/cjs/components/livechatwidget/common/createAdapter.js +13 -1
  24. package/lib/cjs/components/livechatwidget/common/createMarkdown.js +31 -30
  25. package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +14 -17
  26. package/lib/cjs/components/livechatwidget/common/endChat.js +93 -10
  27. package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +27 -3
  28. package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +144 -39
  29. package/lib/cjs/components/livechatwidget/common/registerTelemetryLoggers.js +3 -15
  30. package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +0 -4
  31. package/lib/cjs/components/livechatwidget/common/shareObservable.js +45 -0
  32. package/lib/cjs/components/livechatwidget/common/startChat.js +157 -50
  33. package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +272 -72
  34. package/lib/cjs/components/postchatloadingpanestateful/PostChatLoadingPaneStateful.js +8 -0
  35. package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +5 -10
  36. package/lib/cjs/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +17 -1
  37. package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +80 -0
  38. package/lib/cjs/components/webchatcontainerstateful/common/mockchatsdk.js +2 -0
  39. package/lib/cjs/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.js +1 -0
  40. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.js +14 -0
  41. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +16 -2
  42. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.js +52 -0
  43. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.js +98 -0
  44. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.js +117 -0
  45. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +45 -0
  46. package/lib/cjs/contexts/common/ConversationState.js +3 -2
  47. package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +10 -7
  48. package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +4 -2
  49. package/lib/cjs/contexts/createReducer.js +24 -7
  50. package/lib/cjs/controller/componentController.js +3 -3
  51. package/lib/cjs/plugins/newMessageEventHandler.js +10 -13
  52. package/lib/esm/common/Constants.js +46 -5
  53. package/lib/esm/common/telemetry/TelemetryConstants.js +38 -3
  54. package/lib/esm/common/telemetry/TelemetryHelper.js +13 -1
  55. package/lib/esm/common/telemetry/TelemetryManager.js +9 -1
  56. package/lib/esm/common/telemetry/defaultConfigs/defaultTelemetryConfiguration.js +4 -1
  57. package/lib/esm/common/telemetry/loggers/ariaTelemetryLogger.js +36 -14
  58. package/lib/esm/common/telemetry/loggers/consoleLogger.js +6 -5
  59. package/lib/esm/common/utils.js +64 -1
  60. package/lib/esm/components/callingcontainerstateful/CallingContainerStateful.js +14 -0
  61. package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +22 -7
  62. package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +7 -38
  63. package/lib/esm/components/footerstateful/FooterStateful.js +1 -2
  64. package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +9 -3
  65. package/lib/esm/components/headerstateful/HeaderStateful.js +5 -10
  66. package/lib/esm/components/livechatwidget/common/ActivityStreamHandler.js +34 -0
  67. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js +14 -0
  68. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/IActivitySubscriber.js +1 -0
  69. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js +29 -0
  70. package/lib/esm/components/livechatwidget/common/ChatAdapterShim.js +59 -0
  71. package/lib/esm/components/livechatwidget/common/Deferred.js +33 -0
  72. package/lib/esm/components/livechatwidget/common/authHelper.js +39 -0
  73. package/lib/esm/components/livechatwidget/common/createAdapter.js +12 -2
  74. package/lib/esm/components/livechatwidget/common/createMarkdown.js +31 -30
  75. package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +14 -18
  76. package/lib/esm/components/livechatwidget/common/endChat.js +89 -11
  77. package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +25 -5
  78. package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +134 -41
  79. package/lib/esm/components/livechatwidget/common/registerTelemetryLoggers.js +3 -13
  80. package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +0 -4
  81. package/lib/esm/components/livechatwidget/common/shareObservable.js +38 -0
  82. package/lib/esm/components/livechatwidget/common/startChat.js +152 -53
  83. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +260 -77
  84. package/lib/esm/components/postchatloadingpanestateful/PostChatLoadingPaneStateful.js +6 -0
  85. package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +7 -11
  86. package/lib/esm/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +17 -1
  87. package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +72 -0
  88. package/lib/esm/components/webchatcontainerstateful/common/mockchatsdk.js +2 -0
  89. package/lib/esm/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.js +1 -0
  90. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.js +5 -0
  91. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +16 -2
  92. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.js +41 -0
  93. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.js +94 -0
  94. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.js +107 -0
  95. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +32 -0
  96. package/lib/esm/contexts/common/ConversationState.js +3 -2
  97. package/lib/esm/contexts/common/LiveChatWidgetActionType.js +10 -7
  98. package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +4 -2
  99. package/lib/esm/contexts/createReducer.js +24 -7
  100. package/lib/esm/controller/componentController.js +3 -3
  101. package/lib/esm/plugins/newMessageEventHandler.js +10 -12
  102. package/lib/types/common/Constants.d.ts +25 -2
  103. package/lib/types/common/interfaces/IContextDataStore.d.ts +2 -2
  104. package/lib/types/common/telemetry/TelemetryConstants.d.ts +32 -5
  105. package/lib/types/common/telemetry/TelemetryHelper.d.ts +2 -0
  106. package/lib/types/common/telemetry/definitions/Payload.d.ts +12 -9
  107. package/lib/types/common/telemetry/interfaces/ITelemetryConfig.d.ts +3 -3
  108. package/lib/types/common/utils.d.ts +8 -1
  109. package/lib/types/components/confirmationpanestateful/interfaces/IConfirmationPaneStatefulParams.d.ts +4 -4
  110. package/lib/types/components/footerstateful/audionotificationstateful/interfaces/IAudioNotificationStatefulParams.d.ts +0 -1
  111. package/lib/types/components/headerstateful/interfaces/IHeaderStatefulParams.d.ts +2 -1
  112. package/lib/types/components/livechatwidget/common/ActivityStreamHandler.d.ts +14 -0
  113. package/lib/types/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.d.ts +5 -0
  114. package/lib/types/components/livechatwidget/common/ActivitySubscriber/IActivitySubscriber.d.ts +6 -0
  115. package/lib/types/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.d.ts +7 -0
  116. package/lib/types/components/livechatwidget/common/ChatAdapterShim.d.ts +7 -0
  117. package/lib/types/components/livechatwidget/common/Deferred.d.ts +9 -0
  118. package/lib/types/components/livechatwidget/common/authHelper.d.ts +4 -0
  119. package/lib/types/components/livechatwidget/common/endChat.d.ts +4 -1
  120. package/lib/types/components/livechatwidget/common/reconnectChatHelper.d.ts +6 -2
  121. package/lib/types/components/livechatwidget/common/shareObservable.d.ts +1 -0
  122. package/lib/types/components/livechatwidget/common/startChat.d.ts +4 -2
  123. package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetComponentOverrides.d.ts +1 -0
  124. package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetControlProps.d.ts +1 -0
  125. package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +2 -1
  126. package/lib/types/components/reconnectchatpanestateful/interfaces/IReconnectChatPaneStatefulProps.d.ts +1 -1
  127. package/lib/types/components/webchatcontainerstateful/common/mockchatsdk.d.ts +1 -0
  128. package/lib/types/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.d.ts +4 -0
  129. package/lib/types/components/webchatcontainerstateful/interfaces/IWebChatContainerStatefulProps.d.ts +2 -0
  130. package/lib/types/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.d.ts +3 -0
  131. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.d.ts +2 -0
  132. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.d.ts +1 -0
  133. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.d.ts +5 -0
  134. package/lib/types/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.d.ts +1 -0
  135. package/lib/types/contexts/common/ConversationState.d.ts +3 -2
  136. package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +3 -1
  137. package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +11 -8
  138. package/package.json +8 -8
@@ -13,10 +13,6 @@ var _react = _interopRequireWildcard(require("react"));
13
13
 
14
14
  var _utils = require("../../common/utils");
15
15
 
16
- var _Constants = require("../../common/Constants");
17
-
18
- var _ConversationState = require("../../contexts/common/ConversationState");
19
-
20
16
  var _DimLayer = require("../dimlayer/DimLayer");
21
17
 
22
18
  var _LiveChatWidgetActionType = require("../../contexts/common/LiveChatWidgetActionType");
@@ -25,16 +21,12 @@ var _NotificationHandler = require("../webchatcontainerstateful/webchatcontrolle
25
21
 
26
22
  var _NotificationScenarios = require("../webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios");
27
23
 
28
- var _PostChatSurveyMode = require("../postchatsurveypanestateful/enums/PostChatSurveyMode");
29
-
30
24
  var _TelemetryHelper = require("../../common/telemetry/TelemetryHelper");
31
25
 
32
26
  var _useChatAdapterStore = _interopRequireDefault(require("../../hooks/useChatAdapterStore"));
33
27
 
34
28
  var _useChatContextStore = _interopRequireDefault(require("../../hooks/useChatContextStore"));
35
29
 
36
- var _useChatSDKStore = _interopRequireDefault(require("../../hooks/useChatSDKStore"));
37
-
38
30
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
39
31
 
40
32
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
@@ -43,21 +35,14 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
43
35
 
44
36
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
45
37
  const ConfirmationPaneStateful = props => {
46
- var _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _state$domainStates$l4;
47
-
48
38
  const initialTabIndexMap = new Map();
49
- let elements = []; // eslint-disable-next-line @typescript-eslint/no-explicit-any
50
-
51
- const chatSDK = (0, _useChatSDKStore.default)();
39
+ let elements = [];
52
40
  const [state, dispatch] = (0, _useChatContextStore.default)();
53
41
  const {
54
- endChat
42
+ prepareEndChat
55
43
  } = props; // eslint-disable-next-line @typescript-eslint/no-explicit-any
56
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
57
44
 
58
45
  const [adapter] = (0, _useChatAdapterStore.default)();
59
- const isPostChatEnabled = (_state$domainStates$l = state.domainStates.liveChatConfig) === null || _state$domainStates$l === void 0 ? void 0 : (_state$domainStates$l2 = _state$domainStates$l.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l2 === void 0 ? void 0 : _state$domainStates$l2.msdyn_postconversationsurveyenable;
60
- const postChatSurveyMode = (_state$domainStates$l3 = state.domainStates.liveChatConfig) === null || _state$domainStates$l3 === void 0 ? void 0 : (_state$domainStates$l4 = _state$domainStates$l3.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l4 === void 0 ? void 0 : _state$domainStates$l4.msdyn_postconversationsurveymode;
61
46
  const controlProps = {
62
47
  id: "oc-lcw-confirmation-pane",
63
48
  dir: state.domainStates.globalDir,
@@ -73,29 +58,8 @@ const ConfirmationPaneStateful = props => {
73
58
  });
74
59
 
75
60
  try {
76
- // check agent has joined conversation
77
- const conversationDetails = await chatSDK.getConversationDetails();
78
-
79
- if (isPostChatEnabled === "true" && (conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.canRenderPostChat) === _Constants.Constants.truePascal) {
80
- if (postChatSurveyMode === _PostChatSurveyMode.PostChatSurveyMode.Embed) {
81
- const loadPostChatEvent = {
82
- eventName: _TelemetryConstants.BroadcastEvent.LoadPostChatSurvey
83
- };
84
-
85
- _omnichannelChatComponents.BroadcastService.postMessage(loadPostChatEvent);
86
- } else if (postChatSurveyMode === _PostChatSurveyMode.PostChatSurveyMode.Link) {
87
- const skipEndChatSDK = false;
88
- const skipCloseChat = true;
89
- await endChat(adapter, skipEndChatSDK, skipCloseChat);
90
- dispatch({
91
- type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
92
- payload: _ConversationState.ConversationState.InActive
93
- });
94
- }
95
- } else {
96
- (0, _utils.setTabIndices)(elements, initialTabIndexMap, true);
97
- await endChat(adapter);
98
- }
61
+ (0, _utils.setTabIndices)(elements, initialTabIndexMap, true);
62
+ await prepareEndChat(adapter, state);
99
63
  } catch (ex) {
100
64
  _TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.ERROR, {
101
65
  Event: _TelemetryConstants.TelemetryEvent.GetConversationDetailsCallFailed,
@@ -123,8 +123,7 @@ const FooterStateful = props => {
123
123
  styleProps: footerProps === null || footerProps === void 0 ? void 0 : footerProps.styleProps
124
124
  }), /*#__PURE__*/_react.default.createElement(_AudioNotificationStateful.default, {
125
125
  audioSrc: (audioNotificationProps === null || audioNotificationProps === void 0 ? void 0 : audioNotificationProps.audioSrc) ?? _Audios.NewMessageNotificationSoundBase64,
126
- hideAudioNotificationButton: (footerProps === null || footerProps === void 0 ? void 0 : (_footerProps$controlP4 = footerProps.controlProps) === null || _footerProps$controlP4 === void 0 ? void 0 : _footerProps$controlP4.hideAudioNotificationButton) ?? false,
127
- isAudioMuted: state.appStates.isAudioMuted ?? false
126
+ isAudioMuted: state.appStates.isAudioMuted === null ? (footerProps === null || footerProps === void 0 ? void 0 : (_footerProps$controlP4 = footerProps.controlProps) === null || _footerProps$controlP4 === void 0 ? void 0 : _footerProps$controlP4.hideAudioNotificationButton) ?? false : state.appStates.isAudioMuted ?? false
128
127
  }));
129
128
  };
130
129
 
@@ -116,8 +116,17 @@ const beautifyChatTranscripts = (chatTranscripts, renderMarkDown, attachmentMess
116
116
  let fileAttachmentName = _Constants.TranscriptConstants.DefaultFileAttachmentName;
117
117
  let dialogColor = _Constants.TranscriptConstants.CustomerDialogColor;
118
118
  let fontColor = _Constants.TranscriptConstants.CustomerFontColor;
119
+ const isSystemMessage = value.tags && value.tags.toLowerCase().indexOf(_Constants.Constants.systemMessageTag) !== -1;
120
+ const isControlMessage = value.isControlMessage && value.isControlMessage === true;
119
121
 
120
- if (value.tags && value.tags.toLowerCase().indexOf(_Constants.Constants.systemMessageTag) !== -1 || value.isControlMessage && value.isControlMessage === true || value.contentType && value.contentType.toLowerCase() === _Constants.TranscriptConstants.AdaptiveCardType || value.deliveryMode && value.deliveryMode.toLowerCase() === _Constants.TranscriptConstants.InternalMode) {
122
+ const isAdaptiveCard = value.contentType && value.contentType.toLowerCase() === _Constants.TranscriptConstants.AdaptiveCardType;
123
+
124
+ const isInternalMessage = value.deliveryMode && value.deliveryMode.toLowerCase() === _Constants.TranscriptConstants.InternalMode;
125
+
126
+ const isHiddenMessage = value.tags && value.tags.toLowerCase().indexOf(_Constants.Constants.hiddenTag.toLowerCase()) !== -1;
127
+ const shouldIgnoreMessage = isSystemMessage || isControlMessage || isAdaptiveCard || isInternalMessage || isHiddenMessage;
128
+
129
+ if (shouldIgnoreMessage) {
121
130
  return;
122
131
  } else if (value.from) {
123
132
  if (value.from.application) {
@@ -138,7 +147,7 @@ const beautifyChatTranscripts = (chatTranscripts, renderMarkDown, attachmentMess
138
147
 
139
148
  if (value.attachments && value.attachments.length > 0 && value.attachments[0].name) {
140
149
  fileAttachmentName = value.attachments[0].name;
141
- value.content = attachmentMessage ?? "The following attachment was uploaded during the conversation:" + fileAttachmentName;
150
+ value.content = attachmentMessage ? attachmentMessage + " " + fileAttachmentName : "The following attachment was uploaded during the conversation: " + fileAttachmentName;
142
151
  }
143
152
  }
144
153
 
@@ -69,16 +69,11 @@ const HeaderStateful = props => {
69
69
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_SHOW_CONFIRMATION,
70
70
  payload: true
71
71
  });
72
- } else if (conversationState.current === _ConversationState.ConversationState.Postchat) {
73
- dispatch({
74
- type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_SHOULD_SHOW_POST_CHAT,
75
- payload: false
76
- });
77
- await endChat(adapter);
78
- } else if (conversationState.current === _ConversationState.ConversationState.InActive) {
72
+ } else {
79
73
  const skipEndChatSDK = true;
80
74
  const skipCloseChat = false;
81
- await endChat(adapter, skipEndChatSDK, skipCloseChat);
75
+ const postMessageToOtherTabs = true;
76
+ await endChat(adapter, skipEndChatSDK, skipCloseChat, postMessageToOtherTabs);
82
77
  }
83
78
 
84
79
  dispatch({
@@ -87,8 +82,8 @@ const HeaderStateful = props => {
87
82
  });
88
83
  },
89
84
  ...(headerProps === null || headerProps === void 0 ? void 0 : headerProps.controlProps),
90
- hideTitle: state.appStates.conversationState === _ConversationState.ConversationState.Loading || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP = headerProps.controlProps) === null || _headerProps$controlP === void 0 ? void 0 : _headerProps$controlP.hideTitle),
91
- hideIcon: state.appStates.conversationState === _ConversationState.ConversationState.Loading || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP2 = headerProps.controlProps) === null || _headerProps$controlP2 === void 0 ? void 0 : _headerProps$controlP2.hideIcon),
85
+ hideTitle: state.appStates.conversationState === _ConversationState.ConversationState.Loading || state.appStates.conversationState === _ConversationState.ConversationState.PostchatLoading || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP = headerProps.controlProps) === null || _headerProps$controlP === void 0 ? void 0 : _headerProps$controlP.hideTitle),
86
+ hideIcon: state.appStates.conversationState === _ConversationState.ConversationState.Loading || state.appStates.conversationState === _ConversationState.ConversationState.PostchatLoading || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP2 = headerProps.controlProps) === null || _headerProps$controlP2 === void 0 ? void 0 : _headerProps$controlP2.hideIcon),
92
87
  hideCloseButton: state.appStates.conversationState === _ConversationState.ConversationState.Loading || state.appStates.conversationState === _ConversationState.ConversationState.Prechat || state.appStates.conversationState === _ConversationState.ConversationState.ReconnectChat || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP3 = headerProps.controlProps) === null || _headerProps$controlP3 === void 0 ? void 0 : _headerProps$controlP3.hideCloseButton)
93
88
  };
94
89
  const outOfOfficeControlProps = {
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ActivityStreamHandler = void 0;
7
+
8
+ var _Deferred = require("./Deferred");
9
+
10
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
11
+
12
+ class ActivityStreamHandler {
13
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
14
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
15
+
16
+ /**
17
+ * Use of a deferred pattern, to hold the execution of the activity.
18
+ *
19
+ * */
20
+ static cork() {
21
+ ActivityStreamHandler.restoreDeferred = new _Deferred.Deferred();
22
+ ActivityStreamHandler.restorePromise = ActivityStreamHandler.restoreDeferred.promise;
23
+ }
24
+ /**
25
+ * Resolve the promise, releasing it to continue with the execution of the activity.
26
+ *
27
+ * */
28
+
29
+
30
+ static uncork() {
31
+ ActivityStreamHandler.restoreDeferred.resolve();
32
+ }
33
+
34
+ }
35
+
36
+ exports.ActivityStreamHandler = ActivityStreamHandler;
37
+
38
+ _defineProperty(ActivityStreamHandler, "restoreDeferred", {
39
+ resolve: () => {
40
+ return "initialState";
41
+ }
42
+ });
43
+
44
+ _defineProperty(ActivityStreamHandler, "restorePromise", void 0);
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.DefaultActivitySubscriber = void 0;
7
+
8
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
9
+
10
+ class DefaultActivitySubscriber {
11
+ constructor() {
12
+ _defineProperty(this, "observer", void 0);
13
+ }
14
+
15
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
+ async next(activity) {
17
+ this.observer.next(activity);
18
+ return false;
19
+ }
20
+
21
+ }
22
+
23
+ exports.DefaultActivitySubscriber = DefaultActivitySubscriber;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.PauseActivitySubscriber = void 0;
7
+
8
+ var _ActivityStreamHandler = require("../ActivityStreamHandler");
9
+
10
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
11
+
12
+ class PauseActivitySubscriber {
13
+ constructor() {
14
+ _defineProperty(this, "observer", void 0);
15
+ }
16
+
17
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
18
+ async apply(activity) {
19
+ await _ActivityStreamHandler.ActivityStreamHandler.restorePromise;
20
+ return activity;
21
+ } // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
22
+
23
+
24
+ applicable(activity) {
25
+ return true;
26
+ } // eslint-disable-next-line @typescript-eslint/no-explicit-any
27
+
28
+
29
+ async next(activity) {
30
+ if (this.applicable(activity)) {
31
+ return await this.apply(activity);
32
+ }
33
+
34
+ return activity;
35
+ }
36
+
37
+ }
38
+
39
+ exports.PauseActivitySubscriber = PauseActivitySubscriber;
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ChatAdapterShim = void 0;
7
+
8
+ var _DefaultActivitySubscriber = require("./ActivitySubscriber/DefaultActivitySubscriber");
9
+
10
+ var _shareObservable = require("./shareObservable");
11
+
12
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
13
+
14
+ class ChatAdapterShim {
15
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
17
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
18
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
19
+ constructor(chatAdapter) {
20
+ _defineProperty(this, "chatAdapter", void 0);
21
+
22
+ _defineProperty(this, "activityObserver", void 0);
23
+
24
+ _defineProperty(this, "subscribers", void 0);
25
+
26
+ this.subscribers = [];
27
+ this.chatAdapter = { ...chatAdapter,
28
+ activity$: (0, _shareObservable.shareObservable)( // eslint-disable-next-line @typescript-eslint/no-explicit-any
29
+ new window.Observable(observer => {
30
+ this.activityObserver = observer; // eslint-disable-next-line @typescript-eslint/no-explicit-any
31
+
32
+ const abortController = new window.AbortController();
33
+
34
+ (async () => {
35
+ try {
36
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
37
+ for await (let activity of chatAdapter.activities({
38
+ signal: abortController.signal
39
+ })) {
40
+ for (const subscriber of [...this.subscribers, new _DefaultActivitySubscriber.DefaultActivitySubscriber()]) {
41
+ subscriber.observer = this.activityObserver;
42
+ activity = await subscriber.next(activity);
43
+
44
+ if (!activity) {
45
+ break;
46
+ }
47
+ }
48
+ }
49
+
50
+ observer.complete();
51
+ } catch (error) {
52
+ observer.error(error);
53
+ }
54
+ })();
55
+
56
+ return () => {
57
+ abortController.abort();
58
+ };
59
+ }))
60
+ };
61
+ } // eslint-disable-next-line @typescript-eslint/no-explicit-any
62
+
63
+
64
+ addSubscriber(subscriber) {
65
+ this.subscribers.push(subscriber);
66
+ }
67
+
68
+ }
69
+
70
+ exports.ChatAdapterShim = ChatAdapterShim;
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Deferred = void 0;
7
+
8
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
9
+
10
+ class Deferred {
11
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
12
+ constructor() {
13
+ _defineProperty(this, "_promise", void 0);
14
+
15
+ _defineProperty(this, "_resolve", void 0);
16
+
17
+ _defineProperty(this, "_reject", () => {
18
+ return;
19
+ });
20
+
21
+ _defineProperty(this, "resolve", value => {
22
+ this._resolve(value);
23
+ });
24
+
25
+ _defineProperty(this, "reject", value => {
26
+ this._reject(value);
27
+ });
28
+
29
+ this._promise = new Promise((resolve, reject) => {
30
+ this._resolve = resolve;
31
+ this._reject = reject;
32
+ });
33
+ } // eslint-disable-next-line @typescript-eslint/no-explicit-any
34
+
35
+
36
+ get promise() {
37
+ return this._promise;
38
+ }
39
+
40
+ }
41
+
42
+ exports.Deferred = Deferred;
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.removeAuthTokenProvider = exports.handleAuthentication = void 0;
7
+
8
+ var _TelemetryConstants = require("../../../common/telemetry/TelemetryConstants");
9
+
10
+ var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
11
+
12
+ var _utils = require("../../../common/utils");
13
+
14
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
15
+ const handleAuthentication = async (chatSDK, chatConfig, getAuthToken) => {
16
+ let authClientFunction = undefined;
17
+
18
+ if (chatConfig !== null && chatConfig !== void 0 && chatConfig.LiveChatConfigAuthSettings) {
19
+ var _chatConfig$LiveChatC;
20
+
21
+ authClientFunction = (chatConfig === null || chatConfig === void 0 ? void 0 : (_chatConfig$LiveChatC = chatConfig.LiveChatConfigAuthSettings) === null || _chatConfig$LiveChatC === void 0 ? void 0 : _chatConfig$LiveChatC.msdyn_javascriptclientfunction) ?? undefined;
22
+ }
23
+
24
+ if (getAuthToken && authClientFunction) {
25
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
26
+ Event: _TelemetryConstants.TelemetryEvent.GetAuthTokenCalled
27
+ });
28
+
29
+ const token = await getAuthToken(authClientFunction);
30
+
31
+ if (!(0, _utils.isNullOrEmptyString)(token)) {
32
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
33
+ chatSDK.setAuthTokenProvider(async () => {
34
+ return token;
35
+ });
36
+ } else {
37
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
38
+ Event: _TelemetryConstants.TelemetryEvent.ReceivedNullOrEmptyToken
39
+ });
40
+ }
41
+ }
42
+ }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
43
+
44
+
45
+ exports.handleAuthentication = handleAuthentication;
46
+
47
+ const removeAuthTokenProvider = chatSDK => {
48
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
49
+ chatSDK.authenticatedUserToken = null;
50
+ };
51
+
52
+ exports.removeAuthTokenProvider = removeAuthTokenProvider;
@@ -13,6 +13,10 @@ var _NotificationScenarios = require("../../webchatcontainerstateful/webchatcont
13
13
 
14
14
  var _defaultMiddlewareLocalizedTexts = require("../../webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts");
15
15
 
16
+ var _ChatAdapterShim = require("./ChatAdapterShim");
17
+
18
+ var _PauseActivitySubscriber = require("./ActivitySubscriber/PauseActivitySubscriber");
19
+
16
20
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
17
21
  const createAdapter = async chatSDK => {
18
22
  const chatAdapterOptionalParams = {
@@ -34,7 +38,15 @@ const createAdapter = async chatSDK => {
34
38
  }
35
39
  }
36
40
  };
37
- return await chatSDK.createChatAdapter(chatAdapterOptionalParams);
41
+ let adapter = await chatSDK.createChatAdapter(chatAdapterOptionalParams); //so far, there is no need to convert to the shim adapter when using visual tests
42
+
43
+ if (chatSDK.isMockModeOn !== true) {
44
+ adapter = new _ChatAdapterShim.ChatAdapterShim(adapter);
45
+ adapter.addSubscriber(new _PauseActivitySubscriber.PauseActivitySubscriber());
46
+ return adapter.chatAdapter;
47
+ }
48
+
49
+ return adapter;
38
50
  };
39
51
 
40
52
  exports.createAdapter = createAdapter;
@@ -26,26 +26,40 @@ const createMarkdown = (disableMarkdownMessageFormatting, disableNewLineMarkdown
26
26
  breaks: !disableNewLineMarkdownSupport
27
27
  }); // ToDo: Commenting below usage of plugin until deferred bug is resolved: https://github.com/mayashavin/markdown-it-slack/issues/1
28
28
  // markdown.use(MarkdownSlack);
29
- // Markdown override for open link in new tab
30
- // eslint-disable-next-line @typescript-eslint/no-explicit-any, quotes
29
+ } else {
30
+ markdown = new _markdownIt.default(_Constants.Constants.Zero, {
31
+ html: true,
32
+ linkify: true,
33
+ breaks: !disableNewLineMarkdownSupport
34
+ });
35
+ markdown.enable(["entity", // Rule to process html entity - {, ¯, "
36
+ "linkify", // Rule to replace link-like texts with link nodes
37
+ "html_block", // Rule to process html blocks and paragraphs
38
+ "html_inline", // Rule to process html tags
39
+ "newline" // Rule to proceess '\n'
40
+ ]);
41
+ } // eslint-disable-next-line @typescript-eslint/no-explicit-any
31
42
 
32
- markdown.use(_markdownItForInline.default, "url_new_win", "link_open", function (tokens, idx, env) {
33
- const targetAttrIndex = tokens[idx].attrIndex(_Constants.Constants.Target); // Put a transparent pixel instead of the "open in new window" icon, so developers can easily modify the icon in CSS.
34
43
 
35
- const TRANSPARENT_GIF = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";
44
+ markdown.use(_markdownItForInline.default, "url_new_win", "link_open", function (tokens, idx, env) {
45
+ const targetAttrIndex = tokens[idx].attrIndex(_Constants.Constants.Target); // Put a transparent pixel instead of the "open in new window" icon, so developers can easily modify the icon in CSS.
36
46
 
37
- if (~targetAttrIndex) {
38
- tokens[idx].attrs[targetAttrIndex][1] = _Constants.Constants.Blank;
39
- } else {
40
- tokens[idx].attrPush([_Constants.Constants.Target, _Constants.Constants.Blank]);
41
- }
47
+ const TRANSPARENT_GIF = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";
48
+
49
+ if (~targetAttrIndex) {
50
+ tokens[idx].attrs[targetAttrIndex][1] = _Constants.Constants.Blank;
51
+ } else {
52
+ tokens[idx].attrPush([_Constants.Constants.Target, _Constants.Constants.Blank]);
53
+ }
54
+
55
+ const relAttrIndex = tokens[idx].attrIndex(_Constants.Constants.TargetRelationship);
42
56
 
43
- const relAttrIndex = tokens[idx].attrIndex(_Constants.Constants.TargetRelationship);
57
+ if (~relAttrIndex) {
58
+ tokens[idx].attrs[relAttrIndex][1] = _Constants.Constants.TargetRelationshipAttributes;
59
+ } else {
60
+ tokens[idx].attrPush([_Constants.Constants.TargetRelationship, _Constants.Constants.TargetRelationshipAttributes]);
44
61
 
45
- if (~relAttrIndex) {
46
- tokens[idx].attrs[relAttrIndex][1] = _Constants.Constants.TargetRelationshipAttributes;
47
- } else {
48
- tokens[idx].attrPush([_Constants.Constants.TargetRelationship, _Constants.Constants.TargetRelationshipAttributes]);
62
+ if (!disableMarkdownMessageFormatting) {
49
63
  tokens[idx].attrPush([_Constants.Constants.Title, _defaultMarkdownLocalizedTexts.defaultMarkdownLocalizedTexts.MARKDOWN_EXTERNAL_LINK_ALT]); // eslint-disable-next-line quotes
50
64
 
51
65
  const iconTokens = markdown.parseInline(`![${_defaultMarkdownLocalizedTexts.defaultMarkdownLocalizedTexts.MARKDOWN_EXTERNAL_LINK_ALT}](${TRANSPARENT_GIF})`, env)[0].children;
@@ -55,21 +69,8 @@ const createMarkdown = (disableMarkdownMessageFormatting, disableNewLineMarkdown
55
69
  tokens.splice(idx + 2, 0, ...iconTokens);
56
70
  }
57
71
  }
58
- });
59
- } else {
60
- markdown = new _markdownIt.default(_Constants.Constants.Zero, {
61
- html: true,
62
- linkify: true,
63
- breaks: !disableNewLineMarkdownSupport
64
- });
65
- markdown.enable(["entity", // Rule to process html entity - {, ¯, "
66
- "linkify", // Rule to replace link-like texts with link nodes
67
- "html_block", // Rule to process html blocks and paragraphs
68
- "html_inline", // Rule to process html tags
69
- "newline" // Rule to proceess '\n'
70
- ]);
71
- }
72
-
72
+ }
73
+ });
73
74
  return markdown;
74
75
  };
75
76
 
@@ -27,6 +27,8 @@ var _groupActivitiesMiddleware = require("../../../webchatcontainerstateful/webc
27
27
 
28
28
  var _typingIndicatorMiddleware = require("../../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware");
29
29
 
30
+ var _WebChatLogger = require("../../../webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger");
31
+
30
32
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
31
33
 
32
34
  /* eslint-disable @typescript-eslint/no-empty-function, @typescript-eslint/no-explicit-any */
@@ -272,18 +274,6 @@ const dummyDefaultProps = {
272
274
  width: "50px",
273
275
  fontSize: "18px"
274
276
  },
275
- currentCallTimerStyleProps: {
276
- borderRadius: "2px",
277
- margin: "1px",
278
- color: "#FFFFFF",
279
- paddingTop: "18px",
280
- fontSize: 12,
281
- fontFamily: "Segoe UI, Arial, sans-serif",
282
- backgroundColor: "darkgrey",
283
- height: "45px",
284
- width: "50px",
285
- textAlign: "center"
286
- },
287
277
  videoTileStyleProps: {
288
278
  width: "100%",
289
279
  marginLeft: "auto",
@@ -347,7 +337,9 @@ const dummyDefaultProps = {
347
337
  hideChatTextContainer: false,
348
338
  hideChatSubtitle: false,
349
339
  hideChatTitle: false,
350
- hideNotificationBubble: true
340
+ hideNotificationBubble: true,
341
+ unreadMessageString: "new messages",
342
+ largeUnreadMessageString: "99+"
351
343
  },
352
344
  styleProps: {
353
345
  generalStyleProps: {
@@ -1442,9 +1434,9 @@ const dummyDefaultProps = {
1442
1434
  startNewChatButtonClassName: undefined
1443
1435
  }
1444
1436
  },
1445
- authClientFunction: undefined,
1446
1437
  isReconnectEnabled: undefined,
1447
- reconnectId: undefined
1438
+ reconnectId: undefined,
1439
+ redirectInSameWindow: undefined
1448
1440
  },
1449
1441
  styleProps: {
1450
1442
  generalStyles: {
@@ -1516,7 +1508,7 @@ const dummyDefaultProps = {
1516
1508
  internalErrorBoxClass: undefined,
1517
1509
  internalRenderErrorBox: undefined,
1518
1510
  locale: "en-US",
1519
- onTelemetry: undefined,
1511
+ onTelemetry: (0, _WebChatLogger.createWebChatTelemetry)(),
1520
1512
  overrideLocalizedStrings: undefined,
1521
1513
  renderMarkdown: (0, _createMarkdown.createMarkdown)(false, false),
1522
1514
  scrollToEndButtonMiddleware: undefined,
@@ -1706,8 +1698,13 @@ const dummyDefaultProps = {
1706
1698
  MIDDLEWARE_MESSAGE_RETRY: "Retry",
1707
1699
  PRECHAT_REQUIRED_FIELD_MISSING_MESSAGE: "{0} field is required",
1708
1700
  MARKDOWN_EXTERNAL_LINK_ALT: "Opens in a new window; external."
1701
+ },
1702
+ botMagicCode: {
1703
+ disabled: false,
1704
+ fwdUrl: ""
1709
1705
  }
1710
1706
  },
1711
- telemetryConfig: undefined
1707
+ telemetryConfig: undefined,
1708
+ getAuthToken: undefined
1712
1709
  };
1713
1710
  exports.dummyDefaultProps = dummyDefaultProps;