@microsoft/omnichannel-chat-widget 1.7.8-main.7a07fc5 → 1.7.8-main.8428c08

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 (166) hide show
  1. package/lib/cjs/common/Constants.js +66 -20
  2. package/lib/cjs/common/KeyCodes.js +6 -1
  3. package/lib/cjs/common/contextDataStore/DataStoreManager.js +6 -1
  4. package/lib/cjs/common/facades/FacadeChatSDK.js +392 -295
  5. package/lib/cjs/common/storage/default/defaultCacheManager.js +6 -3
  6. package/lib/cjs/common/telemetry/ScenarioMarker.js +66 -0
  7. package/lib/cjs/common/telemetry/TelemetryConstants.js +179 -148
  8. package/lib/cjs/common/telemetry/TelemetryHelper.js +281 -250
  9. package/lib/cjs/common/telemetry/TelemetryManager.js +31 -11
  10. package/lib/cjs/common/telemetry/defaultConfigs/defaultAppInsightsConfig.js +11 -0
  11. package/lib/cjs/common/telemetry/interfaces/IAppInsightsConfig.js +1 -0
  12. package/lib/cjs/common/telemetry/loggers/appInsightsLogger.js +119 -0
  13. package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +17 -14
  14. package/lib/cjs/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +5 -4
  15. package/lib/cjs/components/footerstateful/FooterStateful.js +13 -8
  16. package/lib/cjs/components/headerstateful/HeaderStateful.js +24 -14
  17. package/lib/cjs/components/livechatwidget/common/ActivityStreamHandler.js +32 -19
  18. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +71 -56
  19. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js +17 -8
  20. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/HiddenAdaptiveCardActivitySubscriber.js +65 -52
  21. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js +31 -18
  22. package/lib/cjs/components/livechatwidget/common/ChatAdapterShim.js +14 -6
  23. package/lib/cjs/components/livechatwidget/common/Deferred.js +14 -6
  24. package/lib/cjs/components/livechatwidget/common/chatDisconnectHelper.js +3 -1
  25. package/lib/cjs/components/livechatwidget/common/endChat.js +4 -18
  26. package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +0 -5
  27. package/lib/cjs/components/livechatwidget/common/registerTelemetryLoggers.js +3 -1
  28. package/lib/cjs/components/livechatwidget/common/renderSurveyHelpers.js +7 -4
  29. package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +7 -3
  30. package/lib/cjs/components/livechatwidget/common/startChat.js +5 -26
  31. package/lib/cjs/components/livechatwidget/common/startChatErrorHandler.js +7 -6
  32. package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +28 -20
  33. package/lib/cjs/components/ooohpanestateful/OOOHPaneStateful.js +12 -8
  34. package/lib/cjs/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +31 -10
  35. package/lib/cjs/components/postchatsurveypanestateful/common/isValidSurveyUrl.js +28 -0
  36. package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +9 -6
  37. package/lib/cjs/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +9 -7
  38. package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +4 -3
  39. package/lib/cjs/components/webchatcontainerstateful/common/DemoChatAdapter.js +88 -65
  40. package/lib/cjs/components/webchatcontainerstateful/common/DemoChatSDK.js +26 -7
  41. package/lib/cjs/components/webchatcontainerstateful/common/DesignerChatAdapter.js +49 -26
  42. package/lib/cjs/components/webchatcontainerstateful/common/DesignerChatSDK.js +57 -35
  43. package/lib/cjs/components/webchatcontainerstateful/common/mockadapter.js +62 -52
  44. package/lib/cjs/components/webchatcontainerstateful/common/mockchatsdk.js +95 -61
  45. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.js +6 -1
  46. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/WebChatStoreLoader.js +6 -1
  47. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/markdownrenderers/HyperlinkTextOverrideRenderer.js +53 -39
  48. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/DeliveredTimestamp.js +4 -0
  49. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/notification/NotificationHandler.js +88 -60
  50. package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +18 -6
  51. package/lib/cjs/firstresponselatency/Constants.js +13 -0
  52. package/lib/cjs/firstresponselatency/FirstMessageTrackerFromBot.js +118 -0
  53. package/lib/cjs/firstresponselatency/FirstResponseLatencyTracker.js +201 -0
  54. package/lib/cjs/firstresponselatency/util.js +98 -0
  55. package/lib/cjs/plugins/createChatTranscript.js +92 -62
  56. package/lib/cjs/plugins/newMessageEventHandler.js +102 -88
  57. package/lib/esm/common/Constants.js +64 -19
  58. package/lib/esm/common/KeyCodes.js +6 -1
  59. package/lib/esm/common/contextDataStore/DataStoreManager.js +6 -1
  60. package/lib/esm/common/facades/FacadeChatSDK.js +392 -295
  61. package/lib/esm/common/storage/default/defaultCacheManager.js +6 -1
  62. package/lib/esm/common/telemetry/ScenarioMarker.js +59 -0
  63. package/lib/esm/common/telemetry/TelemetryConstants.js +179 -148
  64. package/lib/esm/common/telemetry/TelemetryHelper.js +281 -250
  65. package/lib/esm/common/telemetry/TelemetryManager.js +31 -11
  66. package/lib/esm/common/telemetry/defaultConfigs/defaultAppInsightsConfig.js +4 -0
  67. package/lib/esm/common/telemetry/interfaces/IAppInsightsConfig.js +1 -0
  68. package/lib/esm/common/telemetry/loggers/appInsightsLogger.js +111 -0
  69. package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +17 -14
  70. package/lib/esm/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +5 -4
  71. package/lib/esm/components/footerstateful/FooterStateful.js +13 -8
  72. package/lib/esm/components/headerstateful/HeaderStateful.js +24 -14
  73. package/lib/esm/components/livechatwidget/common/ActivityStreamHandler.js +32 -19
  74. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +71 -56
  75. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js +17 -8
  76. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/HiddenAdaptiveCardActivitySubscriber.js +65 -52
  77. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js +31 -18
  78. package/lib/esm/components/livechatwidget/common/ChatAdapterShim.js +14 -6
  79. package/lib/esm/components/livechatwidget/common/Deferred.js +14 -6
  80. package/lib/esm/components/livechatwidget/common/chatDisconnectHelper.js +3 -1
  81. package/lib/esm/components/livechatwidget/common/endChat.js +4 -18
  82. package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +1 -6
  83. package/lib/esm/components/livechatwidget/common/registerTelemetryLoggers.js +3 -1
  84. package/lib/esm/components/livechatwidget/common/renderSurveyHelpers.js +7 -4
  85. package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +7 -3
  86. package/lib/esm/components/livechatwidget/common/startChat.js +6 -27
  87. package/lib/esm/components/livechatwidget/common/startChatErrorHandler.js +7 -6
  88. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +28 -20
  89. package/lib/esm/components/ooohpanestateful/OOOHPaneStateful.js +12 -8
  90. package/lib/esm/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +31 -10
  91. package/lib/esm/components/postchatsurveypanestateful/common/isValidSurveyUrl.js +21 -0
  92. package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +9 -6
  93. package/lib/esm/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +9 -7
  94. package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +4 -3
  95. package/lib/esm/components/webchatcontainerstateful/common/DemoChatAdapter.js +88 -65
  96. package/lib/esm/components/webchatcontainerstateful/common/DemoChatSDK.js +26 -7
  97. package/lib/esm/components/webchatcontainerstateful/common/DesignerChatAdapter.js +49 -26
  98. package/lib/esm/components/webchatcontainerstateful/common/DesignerChatSDK.js +57 -35
  99. package/lib/esm/components/webchatcontainerstateful/common/mockadapter.js +63 -52
  100. package/lib/esm/components/webchatcontainerstateful/common/mockchatsdk.js +95 -61
  101. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.js +6 -1
  102. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/WebChatStoreLoader.js +6 -1
  103. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/markdownrenderers/HyperlinkTextOverrideRenderer.js +53 -39
  104. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/DeliveredTimestamp.js +4 -0
  105. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/notification/NotificationHandler.js +88 -60
  106. package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +18 -6
  107. package/lib/esm/firstresponselatency/Constants.js +6 -0
  108. package/lib/esm/firstresponselatency/FirstMessageTrackerFromBot.js +112 -0
  109. package/lib/esm/firstresponselatency/FirstResponseLatencyTracker.js +194 -0
  110. package/lib/esm/firstresponselatency/util.js +87 -0
  111. package/lib/esm/plugins/createChatTranscript.js +92 -62
  112. package/lib/esm/plugins/newMessageEventHandler.js +100 -86
  113. package/lib/types/common/Constants.d.ts +5 -0
  114. package/lib/types/common/facades/FacadeChatSDK.d.ts +1 -0
  115. package/lib/types/common/telemetry/ScenarioMarker.d.ts +19 -0
  116. package/lib/types/common/telemetry/TelemetryConstants.d.ts +50 -33
  117. package/lib/types/common/telemetry/TelemetryHelper.d.ts +5 -0
  118. package/lib/types/common/telemetry/defaultConfigs/defaultAppInsightsConfig.d.ts +2 -0
  119. package/lib/types/common/telemetry/interfaces/IAppInsightsConfig.d.ts +4 -0
  120. package/lib/types/common/telemetry/interfaces/IChatSDKLogger.d.ts +1 -0
  121. package/lib/types/common/telemetry/interfaces/IInternalTelemetryData.d.ts +2 -0
  122. package/lib/types/common/telemetry/loggers/appInsightsLogger.d.ts +5 -0
  123. package/lib/types/components/callingcontainerstateful/CallingContainerStateful.d.ts +2 -1
  124. package/lib/types/components/chatbuttonstateful/ChatButtonStateful.d.ts +2 -1
  125. package/lib/types/components/confirmationpanestateful/ConfirmationPaneStateful.d.ts +2 -1
  126. package/lib/types/components/dimlayer/DimLayer.d.ts +2 -1
  127. package/lib/types/components/draggable/DraggableChatWidget.d.ts +2 -2
  128. package/lib/types/components/draggable/DraggableEventEmitter.d.ts +2 -2
  129. package/lib/types/components/draggable/DraggableEventReceiver.d.ts +2 -2
  130. package/lib/types/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.d.ts +2 -1
  131. package/lib/types/components/footerstateful/FooterStateful.d.ts +2 -1
  132. package/lib/types/components/footerstateful/audionotificationstateful/AudioNotificationStateful.d.ts +2 -1
  133. package/lib/types/components/headerstateful/HeaderStateful.d.ts +2 -1
  134. package/lib/types/components/livechatwidget/LiveChatWidget.d.ts +2 -1
  135. package/lib/types/components/livechatwidget/common/createFooter.d.ts +2 -1
  136. package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +2 -0
  137. package/lib/types/components/loadingpanestateful/LoadingPaneStateful.d.ts +2 -1
  138. package/lib/types/components/notificationpanestateful/NotificationPaneStateful.d.ts +2 -1
  139. package/lib/types/components/ooohpanestateful/OOOHPaneStateful.d.ts +2 -1
  140. package/lib/types/components/postchatloadingpanestateful/PostChatLoadingPaneStateful.d.ts +2 -1
  141. package/lib/types/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.d.ts +2 -1
  142. package/lib/types/components/postchatsurveypanestateful/common/isValidSurveyUrl.d.ts +2 -0
  143. package/lib/types/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.d.ts +2 -1
  144. package/lib/types/components/proactivechatpanestateful/ProactiveChatPaneStateful.d.ts +2 -1
  145. package/lib/types/components/reconnectchatpanestateful/ReconnectChatPaneStateful.d.ts +2 -1
  146. package/lib/types/components/startchaterrorpanestateful/StartChatErrorPaneStateful.d.ts +2 -1
  147. package/lib/types/components/webchatcontainerstateful/WebChatContainerStateful.d.ts +2 -1
  148. package/lib/types/components/webchatcontainerstateful/interfaces/IWebChatProps.d.ts +2 -2
  149. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/Attachment.d.ts +2 -1
  150. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/AttachmentContent.d.ts +2 -1
  151. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/AttachmentIcon.d.ts +2 -1
  152. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/DownloadBlockedAttachment.d.ts +2 -1
  153. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/MaliciousAttachment.d.ts +2 -1
  154. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/ScanInProgressAttachment.d.ts +2 -1
  155. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/Spinner.d.ts +2 -1
  156. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/avatarMiddleware.d.ts +1 -1
  157. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/DeliveredTimestamp.d.ts +2 -1
  158. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.d.ts +2 -1
  159. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.d.ts +2 -1
  160. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware.d.ts +2 -1
  161. package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +1 -1
  162. package/lib/types/firstresponselatency/Constants.d.ts +30 -0
  163. package/lib/types/firstresponselatency/FirstMessageTrackerFromBot.d.ts +1 -0
  164. package/lib/types/firstresponselatency/FirstResponseLatencyTracker.d.ts +22 -0
  165. package/lib/types/firstresponselatency/util.d.ts +7 -0
  166. package/package.json +27 -13
@@ -7,11 +7,15 @@ exports.MockChatSDK = void 0;
7
7
  var _mockadapter = _interopRequireDefault(require("./mockadapter"));
8
8
  var _Constants = require("../../../common/Constants");
9
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
11
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
12
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
10
13
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
11
14
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
12
15
  function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
13
- class MockChatSDK {
14
- constructor() {
16
+ let MockChatSDK = /*#__PURE__*/function () {
17
+ function MockChatSDK() {
18
+ _classCallCheck(this, MockChatSDK);
15
19
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
20
  _defineProperty(this, "sleep", ms => new Promise(r => setTimeout(r, ms)));
17
21
  _defineProperty(this, "isMockModeOn", true);
@@ -21,64 +25,94 @@ class MockChatSDK {
21
25
  orgUrl: "https://contoso.crm.dynamics.com"
22
26
  });
23
27
  }
24
- async initialize() {
25
- return this.getLiveChatConfig();
26
- }
27
- async startChat() {
28
- await this.sleep(1000);
29
- }
30
- endChat() {
31
- return null;
32
- }
33
- getChatToken() {
34
- return null;
35
- }
36
- createChatAdapter() {
37
- return new _mockadapter.default();
38
- }
28
+ _createClass(MockChatSDK, [{
29
+ key: "initialize",
30
+ value: async function initialize() {
31
+ return this.getLiveChatConfig();
32
+ }
33
+ }, {
34
+ key: "startChat",
35
+ value: async function startChat() {
36
+ await this.sleep(1000);
37
+ }
38
+ }, {
39
+ key: "endChat",
40
+ value: function endChat() {
41
+ return null;
42
+ }
43
+ }, {
44
+ key: "getChatToken",
45
+ value: function getChatToken() {
46
+ return null;
47
+ }
48
+ }, {
49
+ key: "createChatAdapter",
50
+ value: function createChatAdapter() {
51
+ return new _mockadapter.default();
52
+ }
39
53
 
40
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
41
- getPreChatSurvey(parseToJson) {
42
- return "";
43
- }
44
- getConversationDetails() {
45
- return {
46
- State: "Active",
47
- conversationId: "",
48
- canRenderPostChat: "",
49
- participantType: _Constants.ParticipantType.User
50
- };
51
- }
52
- getCurrentLiveChatContext() {
53
- return {
54
- chatToken: {},
55
- requestId: ""
56
- };
57
- }
58
- onNewMessage() {
59
- return null;
60
- }
61
- getChatReconnectContext() {
62
- return {
63
- reconnectId: "123"
64
- };
65
- }
66
- getVoiceVideoCalling() {
67
- return null;
68
- }
69
- setAuthTokenProvider() {
70
- return null;
71
- }
72
- getLiveChatConfig() {
73
- return {
74
- LiveWSAndLiveChatEngJoin: {
75
- msdyn_postconversationsurveyenable: "true",
76
- msdyn_conversationmode: "192350000"
77
- }
78
- };
79
- }
80
- sendTypingEvent() {
81
- return null;
82
- }
83
- }
54
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
55
+ }, {
56
+ key: "getPreChatSurvey",
57
+ value: function getPreChatSurvey(parseToJson) {
58
+ return "";
59
+ }
60
+ }, {
61
+ key: "getConversationDetails",
62
+ value: function getConversationDetails() {
63
+ return {
64
+ State: "Active",
65
+ conversationId: "",
66
+ canRenderPostChat: "",
67
+ participantType: _Constants.ParticipantType.User
68
+ };
69
+ }
70
+ }, {
71
+ key: "getCurrentLiveChatContext",
72
+ value: function getCurrentLiveChatContext() {
73
+ return {
74
+ chatToken: {},
75
+ requestId: ""
76
+ };
77
+ }
78
+ }, {
79
+ key: "onNewMessage",
80
+ value: function onNewMessage() {
81
+ return null;
82
+ }
83
+ }, {
84
+ key: "getChatReconnectContext",
85
+ value: function getChatReconnectContext() {
86
+ return {
87
+ reconnectId: "123"
88
+ };
89
+ }
90
+ }, {
91
+ key: "getVoiceVideoCalling",
92
+ value: function getVoiceVideoCalling() {
93
+ return null;
94
+ }
95
+ }, {
96
+ key: "setAuthTokenProvider",
97
+ value: function setAuthTokenProvider() {
98
+ return null;
99
+ }
100
+ }, {
101
+ key: "getLiveChatConfig",
102
+ value: function getLiveChatConfig() {
103
+ return {
104
+ LiveWSAndLiveChatEngJoin: {
105
+ msdyn_postconversationsurveyenable: "true",
106
+ msdyn_conversationmode: "192350000"
107
+ }
108
+ };
109
+ }
110
+ }, {
111
+ key: "sendTypingEvent",
112
+ value: function sendTypingEvent() {
113
+ return null;
114
+ }
115
+ }]);
116
+ return MockChatSDK;
117
+ }();
84
118
  exports.MockChatSDK = MockChatSDK;
@@ -4,9 +4,14 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.BotMagicCodeStore = void 0;
7
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
8
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
9
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
7
10
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
8
11
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
9
12
  function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
10
- class BotMagicCodeStore {}
13
+ let BotMagicCodeStore = /*#__PURE__*/_createClass(function BotMagicCodeStore() {
14
+ _classCallCheck(this, BotMagicCodeStore);
15
+ });
11
16
  exports.BotMagicCodeStore = BotMagicCodeStore;
12
17
  _defineProperty(BotMagicCodeStore, "botOAuthSignInId", "");
@@ -4,10 +4,15 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.WebChatStoreLoader = void 0;
7
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
8
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
9
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
7
10
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
8
11
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
9
12
  function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
10
- class WebChatStoreLoader {}
13
+ let WebChatStoreLoader = /*#__PURE__*/_createClass(function WebChatStoreLoader() {
14
+ _classCallCheck(this, WebChatStoreLoader);
15
+ });
11
16
  exports.WebChatStoreLoader = WebChatStoreLoader;
12
17
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
13
18
  _defineProperty(WebChatStoreLoader, "store", void 0);
@@ -7,58 +7,72 @@ exports.default = void 0;
7
7
  var _dompurify = _interopRequireDefault(require("dompurify"));
8
8
  var _Constants = require("../../../../common/Constants");
9
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
11
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
12
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
10
13
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
11
14
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
12
15
  function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
13
- class HyperlinkTextOverrideRenderer {
14
- constructor(hyperlinkTextOverride) {
16
+ let HyperlinkTextOverrideRenderer = /*#__PURE__*/function () {
17
+ function HyperlinkTextOverrideRenderer(hyperlinkTextOverride) {
18
+ _classCallCheck(this, HyperlinkTextOverrideRenderer);
15
19
  _defineProperty(this, "hyperlinkTextOverride", void 0);
16
20
  this.hyperlinkTextOverride = hyperlinkTextOverride;
17
21
  }
18
- convertTextToHtmlNode(text) {
19
- const htmlNode = document.createElement(_Constants.HtmlAttributeNames.div);
20
- try {
21
- text = _dompurify.default.sanitize(text, {
22
- ADD_ATTR: ["target"]
23
- });
24
- htmlNode.innerHTML = text;
25
- } catch {
22
+ _createClass(HyperlinkTextOverrideRenderer, [{
23
+ key: "convertTextToHtmlNode",
24
+ value: function convertTextToHtmlNode(text) {
25
+ const htmlNode = document.createElement(_Constants.HtmlAttributeNames.div);
26
+ try {
27
+ text = _dompurify.default.sanitize(text, {
28
+ ADD_ATTR: ["target"]
29
+ });
30
+ htmlNode.innerHTML = text;
31
+ } catch {
32
+ return htmlNode;
33
+ }
26
34
  return htmlNode;
27
35
  }
28
- return htmlNode;
29
- }
30
- processANode(htmlNode) {
31
- // eslint-disable-line @typescript-eslint/no-explicit-any
32
- const aTags = htmlNode.getElementsByTagName(_Constants.HtmlAttributeNames.aTagName);
33
- for (let index = 0; index < aTags.length; index++) {
34
- const aNode = aTags[index];
35
- if (!aNode || !aNode.tagName || aNode.tagName.toLowerCase() !== _Constants.HtmlAttributeNames.aTagName || !aNode.href) continue;
36
- if (aNode.href !== aNode.text.trim()) {
37
- aNode.text = aNode.href;
36
+ }, {
37
+ key: "processANode",
38
+ value: function processANode(htmlNode) {
39
+ // eslint-disable-line @typescript-eslint/no-explicit-any
40
+ const aTags = htmlNode.getElementsByTagName(_Constants.HtmlAttributeNames.aTagName);
41
+ for (let index = 0; index < aTags.length; index++) {
42
+ const aNode = aTags[index];
43
+ if (!aNode || !aNode.tagName || aNode.tagName.toLowerCase() !== _Constants.HtmlAttributeNames.aTagName || !aNode.href) continue;
44
+ if (aNode.href !== aNode.text.trim()) {
45
+ aNode.text = aNode.href;
46
+ }
38
47
  }
39
48
  }
40
- }
41
- applicable(text) {
42
- if (!this.hyperlinkTextOverride) {
43
- return false;
49
+ }, {
50
+ key: "applicable",
51
+ value: function applicable(text) {
52
+ if (!this.hyperlinkTextOverride) {
53
+ return false;
54
+ }
55
+ try {
56
+ const htmlNode = this.convertTextToHtmlNode(text);
57
+ const aNodes = htmlNode.getElementsByTagName(_Constants.HtmlAttributeNames.aTagName);
58
+ return !!aNodes && aNodes.length && aNodes.length > 0;
59
+ } catch {
60
+ return false;
61
+ }
44
62
  }
45
- try {
63
+ }, {
64
+ key: "render",
65
+ value: function render(text) {
66
+ if (!this.applicable(text)) {
67
+ return text;
68
+ }
46
69
  const htmlNode = this.convertTextToHtmlNode(text);
47
- const aNodes = htmlNode.getElementsByTagName(_Constants.HtmlAttributeNames.aTagName);
48
- return !!aNodes && aNodes.length && aNodes.length > 0;
49
- } catch {
50
- return false;
51
- }
52
- }
53
- render(text) {
54
- if (!this.applicable(text)) {
70
+ this.processANode(htmlNode);
71
+ text = htmlNode.innerHTML;
55
72
  return text;
56
73
  }
57
- const htmlNode = this.convertTextToHtmlNode(text);
58
- this.processANode(htmlNode);
59
- text = htmlNode.innerHTML;
60
- return text;
61
- }
62
- }
74
+ }]);
75
+ return HyperlinkTextOverrideRenderer;
76
+ }();
63
77
  var _default = HyperlinkTextOverrideRenderer;
64
78
  exports.default = _default;
@@ -41,6 +41,10 @@ const DeliveredTimestamp = _ref => {
41
41
  return /*#__PURE__*/_react.default.createElement("span", {
42
42
  dir: "ltr"
43
43
  }, (0, _utils.getTimestampHourMinute)(timestamp));
44
+ } else {
45
+ return /*#__PURE__*/_react.default.createElement("span", {
46
+ dir: dir
47
+ }, (0, _utils.getTimestampHourMinute)(timestamp));
44
48
  }
45
49
  return timeString;
46
50
  };
@@ -11,74 +11,102 @@ var _WebChatStoreLoader = require("../WebChatStoreLoader");
11
11
  var _utils = require("../../../../common/utils");
12
12
  var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
13
13
  var _TelemetryConstants = require("../../../../common/telemetry/TelemetryConstants");
14
- class NotificationHandler {
15
- static notify(id, level, message) {
16
- if (_WebChatStoreLoader.WebChatStoreLoader.store) {
17
- _WebChatStoreLoader.WebChatStoreLoader.store.dispatch({
18
- type: _WebChatActionType.WebChatActionType.WEB_CHAT_SET_NOTIFICATION,
19
- payload: {
20
- id,
21
- level,
22
- message
23
- }
24
- });
25
- NotificationHandler.setFocusOnNotificationCloseButton();
26
- }
14
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
15
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
16
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
17
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
18
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
19
+ let NotificationHandler = /*#__PURE__*/function () {
20
+ function NotificationHandler() {
21
+ _classCallCheck(this, NotificationHandler);
27
22
  }
28
- static dismissNotification(id) {
29
- if (_WebChatStoreLoader.WebChatStoreLoader.store) {
30
- _WebChatStoreLoader.WebChatStoreLoader.store.dispatch({
31
- type: _WebChatActionType.WebChatActionType.WEB_CHAT_DISMISS_NOTIFICATION,
23
+ _createClass(NotificationHandler, null, [{
24
+ key: "notify",
25
+ value: function notify(id, level, message) {
26
+ if (_WebChatStoreLoader.WebChatStoreLoader.store) {
27
+ _WebChatStoreLoader.WebChatStoreLoader.store.dispatch({
28
+ type: _WebChatActionType.WebChatActionType.WEB_CHAT_SET_NOTIFICATION,
29
+ payload: {
30
+ id,
31
+ level,
32
+ message
33
+ }
34
+ });
35
+ NotificationHandler.setFocusOnNotificationCloseButton();
36
+ }
37
+ }
38
+ }, {
39
+ key: "dismissNotification",
40
+ value: function dismissNotification(id) {
41
+ if (_WebChatStoreLoader.WebChatStoreLoader.store) {
42
+ _WebChatStoreLoader.WebChatStoreLoader.store.dispatch({
43
+ type: _WebChatActionType.WebChatActionType.WEB_CHAT_DISMISS_NOTIFICATION,
44
+ payload: {
45
+ id
46
+ }
47
+ });
48
+ }
49
+ }
50
+ }, {
51
+ key: "notifyError",
52
+ value: function notifyError(id, message) {
53
+ _omnichannelChatComponents.BroadcastService.postMessage({
54
+ eventName: _TelemetryConstants.BroadcastEvent.OnWidgetError,
32
55
  payload: {
33
- id
56
+ errorMessage: message
34
57
  }
35
58
  });
59
+ this.notify(id, _NotificationLevel.NotificationLevel.Error, message);
36
60
  }
37
- }
38
- static notifyError(id, message) {
39
- _omnichannelChatComponents.BroadcastService.postMessage({
40
- eventName: _TelemetryConstants.BroadcastEvent.OnWidgetError,
41
- payload: {
42
- errorMessage: message
61
+ }, {
62
+ key: "notifyWarning",
63
+ value: function notifyWarning(id, message) {
64
+ this.notify(id, _NotificationLevel.NotificationLevel.Warning, message);
65
+ }
66
+ }, {
67
+ key: "notifyInfo",
68
+ value: function notifyInfo(id, message) {
69
+ this.notify(id, _NotificationLevel.NotificationLevel.Info, message);
70
+ }
71
+ }, {
72
+ key: "notifySuccess",
73
+ value: function notifySuccess(id, message) {
74
+ this.notify(id, _NotificationLevel.NotificationLevel.Success, message);
75
+ }
76
+ }, {
77
+ key: "notifyWithLevel",
78
+ value: function notifyWithLevel(id, message, level) {
79
+ if (!level) {
80
+ this.notifyInfo(id, message);
81
+ } else {
82
+ this.notify(id, level, message);
43
83
  }
44
- });
45
- this.notify(id, _NotificationLevel.NotificationLevel.Error, message);
46
- }
47
- static notifyWarning(id, message) {
48
- this.notify(id, _NotificationLevel.NotificationLevel.Warning, message);
49
- }
50
- static notifyInfo(id, message) {
51
- this.notify(id, _NotificationLevel.NotificationLevel.Info, message);
52
- }
53
- static notifySuccess(id, message) {
54
- this.notify(id, _NotificationLevel.NotificationLevel.Success, message);
55
- }
56
- static notifyWithLevel(id, message, level) {
57
- if (!level) {
58
- this.notifyInfo(id, message);
59
- } else {
60
- this.notify(id, level, message);
61
84
  }
62
- }
63
85
 
64
- /* Bypass WebChat behavior and focus on banner close button */
65
- static setFocusOnNotificationCloseButton() {
66
- const expandButton = document.querySelector(`#${_Constants.HtmlIdNames.MSLiveChatWidget} .${_Constants.HtmlClassNames.webChatBannerExpandButton}`);
67
- if (expandButton) {
68
- expandButton.focus();
69
- return;
86
+ /* Bypass WebChat behavior and focus on banner close button */
87
+ }, {
88
+ key: "setFocusOnNotificationCloseButton",
89
+ value: function setFocusOnNotificationCloseButton() {
90
+ const expandButton = document.querySelector(`#${_Constants.HtmlIdNames.MSLiveChatWidget} .${_Constants.HtmlClassNames.webChatBannerExpandButton}`);
91
+ if (expandButton) {
92
+ expandButton.focus();
93
+ return;
94
+ }
95
+ const closeButton = document.querySelector(`#${_Constants.HtmlIdNames.MSLiveChatWidget} .${_Constants.HtmlClassNames.webChatBannerCloseButton}`);
96
+ if (closeButton) {
97
+ closeButton.focus();
98
+ NotificationHandler.registerOnCloseEvent(closeButton);
99
+ return;
100
+ }
70
101
  }
71
- const closeButton = document.querySelector(`#${_Constants.HtmlIdNames.MSLiveChatWidget} .${_Constants.HtmlClassNames.webChatBannerCloseButton}`);
72
- if (closeButton) {
73
- closeButton.focus();
74
- NotificationHandler.registerOnCloseEvent(closeButton);
75
- return;
102
+ }, {
103
+ key: "registerOnCloseEvent",
104
+ value: function registerOnCloseEvent(button) {
105
+ button.onclick = () => {
106
+ (0, _utils.setFocusOnSendBox)();
107
+ };
76
108
  }
77
- }
78
- static registerOnCloseEvent(button) {
79
- button.onclick = () => {
80
- (0, _utils.setFocusOnSendBox)();
81
- };
82
- }
83
- }
109
+ }]);
110
+ return NotificationHandler;
111
+ }();
84
112
  exports.NotificationHandler = NotificationHandler;
@@ -4,14 +4,18 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getLiveChatWidgetContextInitialState = void 0;
7
- var _ConversationState = require("./ConversationState");
8
- var _defaultMiddlewareLocalizedTexts = require("../../components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts");
9
- var _utils = require("../../common/utils");
10
- var _defaultClientDataStoreProvider = require("../../common/storage/default/defaultClientDataStoreProvider");
11
7
  var _Constants = require("../../common/Constants");
8
+ var _utils = require("../../common/utils");
9
+ var _ConversationState = require("./ConversationState");
12
10
  var _StartChatFailureType = require("./StartChatFailureType");
11
+ var _defaultClientDataStoreProvider = require("../../common/storage/default/defaultClientDataStoreProvider");
12
+ var _defaultMiddlewareLocalizedTexts = require("../../components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts");
13
13
  const getLiveChatWidgetContextInitialState = props => {
14
14
  var _props$controlProps, _props$webChatContain;
15
+ const isOutsideOperatingHours = () => {
16
+ var _props$chatConfig, _props$chatConfig$Liv, _props$chatConfig$Liv2;
17
+ return ((_props$chatConfig = props.chatConfig) === null || _props$chatConfig === void 0 ? void 0 : (_props$chatConfig$Liv = _props$chatConfig.LiveWSAndLiveChatEngJoin) === null || _props$chatConfig$Liv === void 0 ? void 0 : (_props$chatConfig$Liv2 = _props$chatConfig$Liv.OutOfOperatingHours) === null || _props$chatConfig$Liv2 === void 0 ? void 0 : _props$chatConfig$Liv2.toString().toLowerCase()) === "true";
18
+ };
15
19
  const widgetCacheId = (0, _utils.getWidgetCacheIdfromProps)(props);
16
20
  const cacheTtlInMins = (props === null || props === void 0 ? void 0 : (_props$controlProps = props.controlProps) === null || _props$controlProps === void 0 ? void 0 : _props$controlProps.cacheTtlInMins) ?? _Constants.Constants.CacheTtlInMinutes;
17
21
  const storageType = (props === null || props === void 0 ? void 0 : props.useSessionStorage) === true ? _Constants.StorageType.sessionStorage : _Constants.StorageType.localStorage;
@@ -28,6 +32,14 @@ const getLiveChatWidgetContextInitialState = props => {
28
32
  if (initialStateFromCache.appStates.conversationState === _ConversationState.ConversationState.Prechat) {
29
33
  initialStateFromCache.appStates.conversationState = _ConversationState.ConversationState.Closed;
30
34
  }
35
+
36
+ // we are always setting the chatConfig from the props to avoid any issues with the cache
37
+ initialStateFromCache.domainStates.liveChatConfig = props.chatConfig;
38
+
39
+ // Cache the result of isOutsideOperatingHours() to ensure consistency
40
+ const outsideOperatingHours = isOutsideOperatingHours();
41
+ initialStateFromCache.appStates.outsideOperatingHours = outsideOperatingHours;
42
+ initialStateFromCache.appStates.conversationState = outsideOperatingHours ? _ConversationState.ConversationState.OutOfOffice : initialStateFromCache.appStates.conversationState;
31
43
  return initialStateFromCache;
32
44
  }
33
45
  const LiveChatWidgetContextInitialState = {
@@ -52,11 +64,11 @@ const getLiveChatWidgetContextInitialState = props => {
52
64
  startChatFailureType: _StartChatFailureType.StartChatFailureType.Generic
53
65
  },
54
66
  appStates: {
55
- conversationState: _ConversationState.ConversationState.Closed,
67
+ conversationState: isOutsideOperatingHours() ? _ConversationState.ConversationState.OutOfOffice : _ConversationState.ConversationState.Closed,
56
68
  isMinimized: undefined,
57
69
  previousElementIdOnFocusBeforeModalOpen: null,
58
70
  startChatFailed: false,
59
- outsideOperatingHours: false,
71
+ outsideOperatingHours: isOutsideOperatingHours(),
60
72
  preChatResponseEmail: "",
61
73
  isAudioMuted: null,
62
74
  newMessage: false,
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ScenarioType = void 0;
7
+ let ScenarioType;
8
+ exports.ScenarioType = ScenarioType;
9
+ (function (ScenarioType) {
10
+ ScenarioType["UserSendMessageStrategy"] = "UserSendMessageStrategy";
11
+ ScenarioType["SystemMessageStrategy"] = "SystemMessageStrategy";
12
+ ScenarioType["ReceivedMessageStrategy"] = "ReceivedMessageStrategy";
13
+ })(ScenarioType || (exports.ScenarioType = ScenarioType = {}));