@microsoft/omnichannel-chat-widget 0.1.0-main.c461296 → 0.1.0-main.cda7a31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -11
- package/lib/cjs/common/Constants.js +50 -6
- package/lib/cjs/common/storage/default/defaultCacheManager.js +34 -0
- package/lib/cjs/common/storage/default/defaultClientDataStoreProvider.js +114 -0
- package/lib/cjs/common/storage/default/defaultInMemoryDataStore.js +86 -0
- package/lib/cjs/common/telemetry/TelemetryConstants.js +51 -3
- package/lib/cjs/common/telemetry/TelemetryHelper.js +13 -0
- package/lib/cjs/common/telemetry/TelemetryManager.js +16 -5
- package/lib/cjs/common/telemetry/defaultConfigs/defaultAriaConfig.js +1 -1
- package/lib/cjs/common/telemetry/defaultConfigs/defaultTelemetryConfiguration.js +4 -1
- package/lib/cjs/common/telemetry/loggers/ariaTelemetryLogger.js +54 -21
- package/lib/cjs/common/telemetry/loggers/consoleLogger.js +6 -5
- package/lib/cjs/common/utils.js +89 -2
- package/lib/cjs/components/callingcontainerstateful/CallingContainerStateful.js +14 -0
- package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +20 -4
- package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +8 -44
- package/lib/cjs/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +4 -4
- package/lib/cjs/components/footerstateful/FooterStateful.js +6 -15
- package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +11 -2
- package/lib/cjs/components/headerstateful/HeaderStateful.js +15 -14
- package/lib/cjs/components/livechatwidget/common/ActivityStreamHandler.js +44 -0
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js +23 -0
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/IActivitySubscriber.js +1 -0
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js +39 -0
- package/lib/cjs/components/livechatwidget/common/ChatAdapterShim.js +70 -0
- package/lib/cjs/components/livechatwidget/common/Deferred.js +42 -0
- package/lib/cjs/components/livechatwidget/common/authHelper.js +65 -0
- package/lib/cjs/components/livechatwidget/common/createAdapter.js +13 -1
- package/lib/cjs/components/livechatwidget/common/createFooter.js +7 -16
- package/lib/cjs/components/livechatwidget/common/createInternetConnectionChangeHandler.js +12 -0
- package/lib/cjs/components/livechatwidget/common/createMarkdown.js +31 -30
- package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +36 -20
- package/lib/cjs/components/livechatwidget/common/endChat.js +93 -10
- package/lib/cjs/components/livechatwidget/common/initCallingSdk.js +1 -1
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +27 -3
- package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +144 -39
- package/lib/cjs/components/livechatwidget/common/registerTelemetryLoggers.js +6 -17
- package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +0 -4
- package/lib/cjs/components/livechatwidget/common/shareObservable.js +45 -0
- package/lib/cjs/components/livechatwidget/common/startChat.js +166 -50
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +310 -73
- package/lib/cjs/components/postchatloadingpanestateful/PostChatLoadingPaneStateful.js +8 -0
- package/lib/cjs/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +6 -4
- package/lib/cjs/components/postchatsurveypanestateful/interfaces/IPostChatSurveyPaneStatefulProps.js +1 -0
- package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +5 -10
- package/lib/cjs/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +17 -1
- package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +98 -2
- package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps.js +4 -1
- package/lib/cjs/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.js +11 -0
- package/lib/cjs/components/webchatcontainerstateful/common/mockchatsdk.js +2 -0
- package/lib/cjs/components/webchatcontainerstateful/interfaces/IAdaptiveCardStyles.js +1 -0
- package/lib/cjs/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.js +1 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.js +14 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +16 -2
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +2 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.js +52 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.js +98 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultReceivedMessageAnchorStyles.js +10 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.js +117 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +45 -0
- package/lib/cjs/contexts/common/ConversationState.js +3 -2
- package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +11 -8
- package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +15 -6
- package/lib/cjs/contexts/createReducer.js +26 -12
- package/lib/cjs/controller/componentController.js +3 -3
- package/lib/cjs/plugins/newMessageEventHandler.js +10 -13
- package/lib/esm/common/Constants.js +46 -5
- package/lib/esm/common/storage/default/defaultCacheManager.js +19 -0
- package/lib/esm/common/storage/default/defaultClientDataStoreProvider.js +102 -0
- package/lib/esm/common/storage/default/defaultInMemoryDataStore.js +71 -0
- package/lib/esm/common/telemetry/TelemetryConstants.js +51 -3
- package/lib/esm/common/telemetry/TelemetryHelper.js +13 -1
- package/lib/esm/common/telemetry/TelemetryManager.js +14 -5
- package/lib/esm/common/telemetry/defaultConfigs/defaultAriaConfig.js +1 -1
- package/lib/esm/common/telemetry/defaultConfigs/defaultTelemetryConfiguration.js +4 -1
- package/lib/esm/common/telemetry/loggers/ariaTelemetryLogger.js +55 -17
- package/lib/esm/common/telemetry/loggers/consoleLogger.js +6 -5
- package/lib/esm/common/utils.js +64 -1
- package/lib/esm/components/callingcontainerstateful/CallingContainerStateful.js +14 -0
- package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +22 -7
- package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +11 -42
- package/lib/esm/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +4 -4
- package/lib/esm/components/footerstateful/FooterStateful.js +6 -15
- package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +9 -3
- package/lib/esm/components/headerstateful/HeaderStateful.js +15 -14
- package/lib/esm/components/livechatwidget/common/ActivityStreamHandler.js +34 -0
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js +14 -0
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/IActivitySubscriber.js +1 -0
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js +29 -0
- package/lib/esm/components/livechatwidget/common/ChatAdapterShim.js +59 -0
- package/lib/esm/components/livechatwidget/common/Deferred.js +33 -0
- package/lib/esm/components/livechatwidget/common/authHelper.js +50 -0
- package/lib/esm/components/livechatwidget/common/createAdapter.js +12 -2
- package/lib/esm/components/livechatwidget/common/createFooter.js +4 -15
- package/lib/esm/components/livechatwidget/common/createInternetConnectionChangeHandler.js +8 -0
- package/lib/esm/components/livechatwidget/common/createMarkdown.js +31 -30
- package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +36 -21
- package/lib/esm/components/livechatwidget/common/endChat.js +89 -11
- package/lib/esm/components/livechatwidget/common/initCallingSdk.js +1 -1
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +25 -5
- package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +134 -41
- package/lib/esm/components/livechatwidget/common/registerTelemetryLoggers.js +5 -14
- package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +0 -4
- package/lib/esm/components/livechatwidget/common/shareObservable.js +38 -0
- package/lib/esm/components/livechatwidget/common/startChat.js +161 -53
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +298 -78
- package/lib/esm/components/postchatloadingpanestateful/PostChatLoadingPaneStateful.js +6 -0
- package/lib/esm/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +5 -4
- package/lib/esm/components/postchatsurveypanestateful/interfaces/IPostChatSurveyPaneStatefulProps.js +1 -0
- package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +7 -11
- package/lib/esm/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +17 -1
- package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +87 -2
- package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps.js +3 -1
- package/lib/esm/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.js +4 -0
- package/lib/esm/components/webchatcontainerstateful/common/mockchatsdk.js +2 -0
- package/lib/esm/components/webchatcontainerstateful/interfaces/IAdaptiveCardStyles.js +1 -0
- package/lib/esm/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.js +1 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.js +5 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +16 -2
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +2 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.js +41 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.js +94 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultReceivedMessageAnchorStyles.js +3 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.js +107 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +32 -0
- package/lib/esm/contexts/common/ConversationState.js +3 -2
- package/lib/esm/contexts/common/LiveChatWidgetActionType.js +11 -8
- package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +13 -6
- package/lib/esm/contexts/createReducer.js +26 -11
- package/lib/esm/controller/componentController.js +3 -3
- package/lib/esm/plugins/newMessageEventHandler.js +10 -12
- package/lib/types/common/Constants.d.ts +25 -2
- package/lib/types/common/interfaces/IContextDataStore.d.ts +2 -2
- package/lib/types/common/storage/default/defaultCacheManager.d.ts +4 -0
- package/lib/types/common/storage/default/defaultClientDataStoreProvider.d.ts +2 -0
- package/lib/types/common/storage/default/defaultInMemoryDataStore.d.ts +6 -0
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +36 -5
- package/lib/types/common/telemetry/TelemetryHelper.d.ts +2 -0
- package/lib/types/common/telemetry/definitions/Payload.d.ts +12 -9
- package/lib/types/common/telemetry/interfaces/ITelemetryConfig.d.ts +3 -3
- package/lib/types/common/utils.d.ts +8 -1
- package/lib/types/components/confirmationpanestateful/interfaces/IConfirmationPaneStatefulParams.d.ts +4 -4
- package/lib/types/components/footerstateful/audionotificationstateful/interfaces/IAudioNotificationStatefulParams.d.ts +0 -1
- package/lib/types/components/headerstateful/interfaces/IHeaderStatefulParams.d.ts +2 -1
- package/lib/types/components/livechatwidget/common/ActivityStreamHandler.d.ts +14 -0
- package/lib/types/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.d.ts +5 -0
- package/lib/types/components/livechatwidget/common/ActivitySubscriber/IActivitySubscriber.d.ts +6 -0
- package/lib/types/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.d.ts +7 -0
- package/lib/types/components/livechatwidget/common/ChatAdapterShim.d.ts +7 -0
- package/lib/types/components/livechatwidget/common/Deferred.d.ts +9 -0
- package/lib/types/components/livechatwidget/common/authHelper.d.ts +5 -0
- package/lib/types/components/livechatwidget/common/endChat.d.ts +4 -1
- package/lib/types/components/livechatwidget/common/reconnectChatHelper.d.ts +6 -2
- package/lib/types/components/livechatwidget/common/shareObservable.d.ts +1 -0
- package/lib/types/components/livechatwidget/common/startChat.d.ts +4 -2
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetComponentOverrides.d.ts +1 -0
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetControlProps.d.ts +1 -0
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +4 -3
- package/lib/types/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.d.ts +2 -2
- package/lib/types/components/postchatsurveypanestateful/interfaces/IPostChatSurveyPaneStatefulProps.d.ts +4 -0
- package/lib/types/components/reconnectchatpanestateful/interfaces/IReconnectChatPaneStatefulProps.d.ts +1 -1
- package/lib/types/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/common/mockchatsdk.d.ts +1 -0
- package/lib/types/components/webchatcontainerstateful/interfaces/IAdaptiveCardStyles.d.ts +4 -0
- package/lib/types/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.d.ts +4 -0
- package/lib/types/components/webchatcontainerstateful/interfaces/IRenderingMiddlewareProps.d.ts +2 -1
- package/lib/types/components/webchatcontainerstateful/interfaces/IWebChatContainerStatefulProps.d.ts +4 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.d.ts +3 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.d.ts +1 -1
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.d.ts +1 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultReceivedMessageAnchorStyles.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.d.ts +5 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.d.ts +1 -0
- package/lib/types/contexts/common/ConversationState.d.ts +3 -2
- package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +4 -2
- package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +12 -9
- package/lib/types/contexts/common/LiveChatWidgetContextInitialState.d.ts +1 -2
- package/package.json +9 -9
|
@@ -15,6 +15,7 @@ exports.ConversationState = ConversationState;
|
|
|
15
15
|
ConversationState[ConversationState["ProactiveChat"] = 4] = "ProactiveChat";
|
|
16
16
|
ConversationState[ConversationState["Active"] = 5] = "Active";
|
|
17
17
|
ConversationState[ConversationState["InActive"] = 6] = "InActive";
|
|
18
|
-
ConversationState[ConversationState["
|
|
19
|
-
ConversationState[ConversationState["
|
|
18
|
+
ConversationState[ConversationState["PostchatLoading"] = 7] = "PostchatLoading";
|
|
19
|
+
ConversationState[ConversationState["Postchat"] = 8] = "Postchat";
|
|
20
|
+
ConversationState[ConversationState["Closed"] = 9] = "Closed";
|
|
20
21
|
})(ConversationState || (exports.ConversationState = ConversationState = {}));
|
|
@@ -14,16 +14,16 @@ exports.LiveChatWidgetActionType = LiveChatWidgetActionType;
|
|
|
14
14
|
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_GLOBAL_DIR"] = 3] = "SET_GLOBAL_DIR";
|
|
15
15
|
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_MINIMIZED"] = 4] = "SET_MINIMIZED";
|
|
16
16
|
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_CONVERSATION_STATE"] = 5] = "SET_CONVERSATION_STATE";
|
|
17
|
-
LiveChatWidgetActionType[LiveChatWidgetActionType["
|
|
17
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_PREVIOUS_FOCUSED_ELEMENT_ID"] = 6] = "SET_PREVIOUS_FOCUSED_ELEMENT_ID";
|
|
18
18
|
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_OUTSIDE_OPERATING_HOURS"] = 7] = "SET_OUTSIDE_OPERATING_HOURS";
|
|
19
19
|
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_PRE_CHAT_SURVEY_RESPONSE"] = 8] = "SET_PRE_CHAT_SURVEY_RESPONSE";
|
|
20
|
-
LiveChatWidgetActionType[LiveChatWidgetActionType["
|
|
21
|
-
LiveChatWidgetActionType[LiveChatWidgetActionType["
|
|
22
|
-
LiveChatWidgetActionType[LiveChatWidgetActionType["
|
|
23
|
-
LiveChatWidgetActionType[LiveChatWidgetActionType["
|
|
24
|
-
LiveChatWidgetActionType[LiveChatWidgetActionType["
|
|
25
|
-
LiveChatWidgetActionType[LiveChatWidgetActionType["
|
|
26
|
-
LiveChatWidgetActionType[LiveChatWidgetActionType["
|
|
20
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_CUSTOM_CONTEXT"] = 9] = "SET_CUSTOM_CONTEXT";
|
|
21
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_SHOW_CONFIRMATION"] = 10] = "SET_SHOW_CONFIRMATION";
|
|
22
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_SHOW_EMAIL_TRANSCRIPT_PANE"] = 11] = "SET_SHOW_EMAIL_TRANSCRIPT_PANE";
|
|
23
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_PRECHAT_RESPONSE_EMAIL"] = 12] = "SET_PRECHAT_RESPONSE_EMAIL";
|
|
24
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_AUDIO_NOTIFICATION"] = 13] = "SET_AUDIO_NOTIFICATION";
|
|
25
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_E2VV_ENABLED"] = 14] = "SET_E2VV_ENABLED";
|
|
26
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_POST_CHAT_CONTEXT"] = 15] = "SET_POST_CHAT_CONTEXT";
|
|
27
27
|
LiveChatWidgetActionType[LiveChatWidgetActionType["SHOW_CALLING_CONTAINER"] = 16] = "SHOW_CALLING_CONTAINER";
|
|
28
28
|
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_INCOMING_CALL"] = 17] = "SET_INCOMING_CALL";
|
|
29
29
|
LiveChatWidgetActionType[LiveChatWidgetActionType["DISABLE_VIDEO_CALL"] = 18] = "DISABLE_VIDEO_CALL";
|
|
@@ -39,4 +39,7 @@ exports.LiveChatWidgetActionType = LiveChatWidgetActionType;
|
|
|
39
39
|
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_CONVERSATION_ENDED_BY_AGENT"] = 28] = "SET_CONVERSATION_ENDED_BY_AGENT";
|
|
40
40
|
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_WIDGET_STATE"] = 29] = "SET_WIDGET_STATE";
|
|
41
41
|
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_LIVE_CHAT_CONTEXT"] = 30] = "SET_LIVE_CHAT_CONTEXT";
|
|
42
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_BOT_OAUTH_SIGNIN_ID"] = 31] = "SET_BOT_OAUTH_SIGNIN_ID";
|
|
43
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_WIDGET_SIZE"] = 32] = "SET_WIDGET_SIZE";
|
|
44
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_WIDGET_INSTANCE_ID"] = 33] = "SET_WIDGET_INSTANCE_ID";
|
|
42
45
|
})(LiveChatWidgetActionType || (exports.LiveChatWidgetActionType = LiveChatWidgetActionType = {}));
|
|
@@ -9,11 +9,18 @@ var _ConversationState = require("./ConversationState");
|
|
|
9
9
|
|
|
10
10
|
var _defaultMiddlewareLocalizedTexts = require("../../components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts");
|
|
11
11
|
|
|
12
|
+
var _utils = require("../../common/utils");
|
|
13
|
+
|
|
14
|
+
var _defaultClientDataStoreProvider = require("../../common/storage/default/defaultClientDataStoreProvider");
|
|
15
|
+
|
|
12
16
|
const getLiveChatWidgetContextInitialState = props => {
|
|
13
|
-
var _props$webChatContain;
|
|
17
|
+
var _props$chatSDK, _props$chatSDK$omnich, _props$chatSDK2, _props$chatSDK2$omnic, _props$controlProps, _props$webChatContain;
|
|
18
|
+
|
|
19
|
+
const widgetCacheId = (0, _utils.getWidgetCacheId)(props === null || props === void 0 ? void 0 : (_props$chatSDK = props.chatSDK) === null || _props$chatSDK === void 0 ? void 0 : (_props$chatSDK$omnich = _props$chatSDK.omnichannelConfig) === null || _props$chatSDK$omnich === void 0 ? void 0 : _props$chatSDK$omnich.orgId, props === null || props === void 0 ? void 0 : (_props$chatSDK2 = props.chatSDK) === null || _props$chatSDK2 === void 0 ? void 0 : (_props$chatSDK2$omnic = _props$chatSDK2.omnichannelConfig) === null || _props$chatSDK2$omnic === void 0 ? void 0 : _props$chatSDK2$omnic.widgetId, (props === null || props === void 0 ? void 0 : (_props$controlProps = props.controlProps) === null || _props$controlProps === void 0 ? void 0 : _props$controlProps.widgetInstanceId) ?? "");
|
|
20
|
+
const initialState = (0, _defaultClientDataStoreProvider.defaultClientDataStoreProvider)().getData(widgetCacheId, "localStorage");
|
|
14
21
|
|
|
15
|
-
if (
|
|
16
|
-
return
|
|
22
|
+
if (!(0, _utils.isNullOrUndefined)(initialState)) {
|
|
23
|
+
return JSON.parse(initialState);
|
|
17
24
|
}
|
|
18
25
|
|
|
19
26
|
const LiveChatWidgetContextInitialState = {
|
|
@@ -27,14 +34,16 @@ const getLiveChatWidgetContextInitialState = props => {
|
|
|
27
34
|
postChatContext: undefined,
|
|
28
35
|
telemetryInternalData: {},
|
|
29
36
|
globalDir: "ltr",
|
|
30
|
-
liveChatContext: undefined
|
|
37
|
+
liveChatContext: undefined,
|
|
38
|
+
customContext: undefined,
|
|
39
|
+
widgetSize: undefined,
|
|
40
|
+
widgetInstanceId: ""
|
|
31
41
|
},
|
|
32
42
|
appStates: {
|
|
33
43
|
conversationState: _ConversationState.ConversationState.Closed,
|
|
34
44
|
isMinimized: false,
|
|
35
|
-
|
|
45
|
+
previousElementIdOnFocusBeforeModalOpen: null,
|
|
36
46
|
outsideOperatingHours: false,
|
|
37
|
-
shouldShowPostChat: false,
|
|
38
47
|
preChatResponseEmail: "",
|
|
39
48
|
isAudioMuted: null,
|
|
40
49
|
newMessage: false,
|
|
@@ -7,8 +7,6 @@ exports.createReducer = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _LiveChatWidgetActionType = require("./common/LiveChatWidgetActionType");
|
|
9
9
|
|
|
10
|
-
var _TelemetryManager = require("../common/telemetry/TelemetryManager");
|
|
11
|
-
|
|
12
10
|
/* eslint-disable indent */
|
|
13
11
|
const createReducer = () => {
|
|
14
12
|
const reducer = (state, action) => {
|
|
@@ -71,10 +69,18 @@ const createReducer = () => {
|
|
|
71
69
|
}
|
|
72
70
|
};
|
|
73
71
|
|
|
74
|
-
case _LiveChatWidgetActionType.LiveChatWidgetActionType.
|
|
72
|
+
case _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CUSTOM_CONTEXT:
|
|
73
|
+
return { ...state,
|
|
74
|
+
domainStates: { ...state.domainStates,
|
|
75
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
76
|
+
customContext: action.payload
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
case _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_PREVIOUS_FOCUSED_ELEMENT_ID:
|
|
75
81
|
return { ...state,
|
|
76
82
|
appStates: { ...state.appStates,
|
|
77
|
-
|
|
83
|
+
previousElementIdOnFocusBeforeModalOpen: action.payload
|
|
78
84
|
}
|
|
79
85
|
};
|
|
80
86
|
|
|
@@ -93,13 +99,6 @@ const createReducer = () => {
|
|
|
93
99
|
}
|
|
94
100
|
};
|
|
95
101
|
|
|
96
|
-
case _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_SHOULD_SHOW_POST_CHAT:
|
|
97
|
-
return { ...state,
|
|
98
|
-
appStates: { ...state.appStates,
|
|
99
|
-
shouldShowPostChat: action.payload
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
|
|
103
102
|
case _LiveChatWidgetActionType.LiveChatWidgetActionType.SHOW_CALLING_CONTAINER:
|
|
104
103
|
return { ...state,
|
|
105
104
|
uiStates: { ...state.uiStates,
|
|
@@ -197,7 +196,6 @@ const createReducer = () => {
|
|
|
197
196
|
};
|
|
198
197
|
|
|
199
198
|
case _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_TELEMETRY_DATA:
|
|
200
|
-
_TelemetryManager.TelemetryManager.InternalTelemetryData = action.payload;
|
|
201
199
|
return { ...state,
|
|
202
200
|
domainStates: { ...state.domainStates,
|
|
203
201
|
telemetryInternalData: action.payload
|
|
@@ -237,6 +235,22 @@ const createReducer = () => {
|
|
|
237
235
|
}
|
|
238
236
|
};
|
|
239
237
|
|
|
238
|
+
case _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_WIDGET_SIZE:
|
|
239
|
+
return { ...state,
|
|
240
|
+
domainStates: { ...state.domainStates,
|
|
241
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
242
|
+
widgetSize: action.payload
|
|
243
|
+
}
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
case _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_WIDGET_INSTANCE_ID:
|
|
247
|
+
return { ...state,
|
|
248
|
+
domainStates: { ...state.domainStates,
|
|
249
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
250
|
+
widgetInstanceId: action.payload
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
|
|
240
254
|
default:
|
|
241
255
|
return state;
|
|
242
256
|
}
|
|
@@ -8,7 +8,7 @@ exports.shouldShowWebChatContainer = exports.shouldShowReconnectChatPane = expor
|
|
|
8
8
|
var _ConversationState = require("../contexts/common/ConversationState");
|
|
9
9
|
|
|
10
10
|
const shouldShowChatButton = state => {
|
|
11
|
-
return state.appStates.isMinimized || state.appStates.conversationState === _ConversationState.ConversationState.Closed;
|
|
11
|
+
return (state.appStates.isMinimized || state.appStates.conversationState === _ConversationState.ConversationState.Closed) && state.appStates.skipChatButtonRendering == false; // Do not show chat button in case of popout
|
|
12
12
|
};
|
|
13
13
|
|
|
14
14
|
exports.shouldShowChatButton = shouldShowChatButton;
|
|
@@ -44,7 +44,7 @@ const shouldShowWebChatContainer = state => {
|
|
|
44
44
|
exports.shouldShowWebChatContainer = shouldShowWebChatContainer;
|
|
45
45
|
|
|
46
46
|
const shouldShowLoadingPane = state => {
|
|
47
|
-
return !state.appStates.isMinimized &&
|
|
47
|
+
return !state.appStates.isMinimized && state.appStates.conversationState === _ConversationState.ConversationState.Loading;
|
|
48
48
|
};
|
|
49
49
|
|
|
50
50
|
exports.shouldShowLoadingPane = shouldShowLoadingPane;
|
|
@@ -56,7 +56,7 @@ const shouldShowReconnectChatPane = state => {
|
|
|
56
56
|
exports.shouldShowReconnectChatPane = shouldShowReconnectChatPane;
|
|
57
57
|
|
|
58
58
|
const shouldShowPostChatLoadingPane = state => {
|
|
59
|
-
return !state.appStates.isMinimized && state.appStates.
|
|
59
|
+
return !state.appStates.isMinimized && state.appStates.conversationState === _ConversationState.ConversationState.PostchatLoading;
|
|
60
60
|
};
|
|
61
61
|
|
|
62
62
|
exports.shouldShowPostChatLoadingPane = shouldShowPostChatLoadingPane;
|
|
@@ -13,8 +13,6 @@ var _Constants = require("../common/Constants");
|
|
|
13
13
|
|
|
14
14
|
var _TelemetryHelper = require("../common/telemetry/TelemetryHelper");
|
|
15
15
|
|
|
16
|
-
var _TelemetryManager = require("../common/telemetry/TelemetryManager");
|
|
17
|
-
|
|
18
16
|
const createOnNewAdapterActivityHandler = (chatId, userId) => {
|
|
19
17
|
const onNewAdapterActivityHandler = activity => {
|
|
20
18
|
var _activity$channelData, _activity$channelData2, _activity$channelData3;
|
|
@@ -29,18 +27,16 @@ const createOnNewAdapterActivityHandler = (chatId, userId) => {
|
|
|
29
27
|
|
|
30
28
|
const raiseMessageEvent = activity => {
|
|
31
29
|
if ((activity === null || activity === void 0 ? void 0 : activity.type) === _Constants.Constants.message) {
|
|
32
|
-
var
|
|
30
|
+
var _text, _text2, _activity$channelData4, _activity$from;
|
|
33
31
|
|
|
34
32
|
const payload = {
|
|
33
|
+
// To identify hidden contents vs empty content
|
|
35
34
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
36
|
-
text: activity === null || activity === void 0 ? void 0 : activity.text,
|
|
37
|
-
id: activity === null || activity === void 0 ? void 0 : activity.id,
|
|
35
|
+
text: (activity === null || activity === void 0 ? void 0 : (_text = activity.text) === null || _text === void 0 ? void 0 : _text.length) >= 1 ? `*contents hidden (${activity === null || activity === void 0 ? void 0 : (_text2 = activity.text) === null || _text2 === void 0 ? void 0 : _text2.length} chars)*` : "",
|
|
38
36
|
type: activity === null || activity === void 0 ? void 0 : activity.type,
|
|
39
37
|
timestamp: activity === null || activity === void 0 ? void 0 : activity.timestamp,
|
|
40
|
-
chatId: chatId,
|
|
41
38
|
userId: userId,
|
|
42
|
-
|
|
43
|
-
channelData: activity === null || activity === void 0 ? void 0 : activity.channelData,
|
|
39
|
+
tags: activity === null || activity === void 0 ? void 0 : (_activity$channelData4 = activity.channelData) === null || _activity$channelData4 === void 0 ? void 0 : _activity$channelData4.tags,
|
|
44
40
|
messageType: ""
|
|
45
41
|
};
|
|
46
42
|
|
|
@@ -59,18 +55,18 @@ const createOnNewAdapterActivityHandler = (chatId, userId) => {
|
|
|
59
55
|
Description: "New message sent"
|
|
60
56
|
});
|
|
61
57
|
} else {
|
|
62
|
-
var _activity$
|
|
58
|
+
var _activity$channelData5, _activity$channelData6;
|
|
63
59
|
|
|
64
|
-
if (activity !== null && activity !== void 0 && (_activity$
|
|
60
|
+
if (activity !== null && activity !== void 0 && (_activity$channelData5 = activity.channelData) !== null && _activity$channelData5 !== void 0 && (_activity$channelData6 = _activity$channelData5.tags) !== null && _activity$channelData6 !== void 0 && _activity$channelData6.includes(_Constants.Constants.systemMessageTag)) {
|
|
65
61
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
66
62
|
payload.messageType = _Constants.Constants.systemMessageTag;
|
|
67
63
|
} else {
|
|
68
|
-
var _activity$
|
|
64
|
+
var _activity$channelData7, _activity$channelData8, _activity$channelData9;
|
|
69
65
|
|
|
70
66
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
71
67
|
const messageHasNoText = !(activity !== null && activity !== void 0 && activity.text); // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
72
68
|
|
|
73
|
-
const messageHasNoTags = !(activity !== null && activity !== void 0 && activity.channelData) || !(activity !== null && activity !== void 0 && (_activity$
|
|
69
|
+
const messageHasNoTags = !(activity !== null && activity !== void 0 && activity.channelData) || !(activity !== null && activity !== void 0 && (_activity$channelData7 = activity.channelData) !== null && _activity$channelData7 !== void 0 && _activity$channelData7.tags) || (activity === null || activity === void 0 ? void 0 : (_activity$channelData8 = activity.channelData) === null || _activity$channelData8 === void 0 ? void 0 : (_activity$channelData9 = _activity$channelData8.tags) === null || _activity$channelData9 === void 0 ? void 0 : _activity$channelData9.length) === 0; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
74
70
|
|
|
75
71
|
const messageHasNoAttachments = !(activity !== null && activity !== void 0 && activity.attachments) || (activity === null || activity === void 0 ? void 0 : activity.attachments.length) === 0;
|
|
76
72
|
|
|
@@ -90,7 +86,8 @@ const createOnNewAdapterActivityHandler = (chatId, userId) => {
|
|
|
90
86
|
|
|
91
87
|
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
92
88
|
Event: _TelemetryConstants.TelemetryEvent.MessageReceived,
|
|
93
|
-
Description: "New message received"
|
|
89
|
+
Description: "New message received",
|
|
90
|
+
Data: payload
|
|
94
91
|
});
|
|
95
92
|
}
|
|
96
93
|
}
|
|
@@ -4,6 +4,10 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
4
4
|
|
|
5
5
|
export class Constants {}
|
|
6
6
|
|
|
7
|
+
_defineProperty(Constants, "magicCodeBroadcastChannel", "MagicCodeChannel");
|
|
8
|
+
|
|
9
|
+
_defineProperty(Constants, "magicCodeResponseBroadcastChannel", "MagicCodeResponseChannel");
|
|
10
|
+
|
|
7
11
|
_defineProperty(Constants, "systemMessageTag", "system");
|
|
8
12
|
|
|
9
13
|
_defineProperty(Constants, "userMessageTag", "user");
|
|
@@ -36,8 +40,6 @@ _defineProperty(Constants, "false", "false");
|
|
|
36
40
|
|
|
37
41
|
_defineProperty(Constants, "maximumUnreadMessageCount", 99);
|
|
38
42
|
|
|
39
|
-
_defineProperty(Constants, "widgetStateDataKey", "LcwChatWidgetState");
|
|
40
|
-
|
|
41
43
|
_defineProperty(Constants, "channelIdKey", "ChannelId-");
|
|
42
44
|
|
|
43
45
|
_defineProperty(Constants, "ChannelId", "lcw");
|
|
@@ -72,6 +74,14 @@ _defineProperty(Constants, "averageWaitTimeMessageTag", "averagewaittime");
|
|
|
72
74
|
|
|
73
75
|
_defineProperty(Constants, "message", "message");
|
|
74
76
|
|
|
77
|
+
_defineProperty(Constants, "hiddenTag", "Hidden");
|
|
78
|
+
|
|
79
|
+
_defineProperty(Constants, "prefixTimestampTag", "ServerMessageTimestamp_");
|
|
80
|
+
|
|
81
|
+
_defineProperty(Constants, "acsChannel", "ACS_CHANNEL");
|
|
82
|
+
|
|
83
|
+
_defineProperty(Constants, "publicMessageTag", "public");
|
|
84
|
+
|
|
75
85
|
_defineProperty(Constants, "supportedAdaptiveCardContentTypes", ["application/vnd.microsoft.card.adaptive", "application/vnd.microsoft.card.audio", "application/vnd.microsoft.card.hero", "application/vnd.microsoft.card.receipt", "application/vnd.microsoft.card.thumbnail", "application/vnd.microsoft.card.signin", "application/vnd.microsoft.card.oauth"]);
|
|
76
86
|
|
|
77
87
|
_defineProperty(Constants, "maxUploadFileSize", "500000");
|
|
@@ -122,8 +132,6 @@ _defineProperty(Constants, "InputSubmit", "InputSubmit");
|
|
|
122
132
|
|
|
123
133
|
_defineProperty(Constants, "ReconnectIdAttributeName", "oc.reconnectid");
|
|
124
134
|
|
|
125
|
-
_defineProperty(Constants, "redirectPageRequest", "redirectPageRequest");
|
|
126
|
-
|
|
127
135
|
_defineProperty(Constants, "LiveChatWidget", "LiveChatWidgetNew");
|
|
128
136
|
|
|
129
137
|
_defineProperty(Constants, "GuidPattern", "xx-x-4m-ym-xxx");
|
|
@@ -148,6 +156,12 @@ _defineProperty(Constants, "internetConnectionTestUrl", "https://ocsdk-prod.azur
|
|
|
148
156
|
|
|
149
157
|
_defineProperty(Constants, "internetConnectionTestUrlText", "Omnichannel Connect Test");
|
|
150
158
|
|
|
159
|
+
_defineProperty(Constants, "ChatWidgetStateChangedPrefix", "ChatWidgetStateChanged");
|
|
160
|
+
|
|
161
|
+
_defineProperty(Constants, "PostChatLoadingDurationInMs", 2000);
|
|
162
|
+
|
|
163
|
+
_defineProperty(Constants, "BrowserUnloadConfirmationMessage", "Do you want to leave chat?");
|
|
164
|
+
|
|
151
165
|
export const Regex = (_class = class Regex {}, _defineProperty(_class, "EmailRegex", "(?:[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*\")@(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?|\\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-zA-Z0-9-]*[a-zA-Z0-9]:(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21-\\x5a\\x53-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])+)\\])"), _class);
|
|
152
166
|
export class HtmlIdNames {}
|
|
153
167
|
|
|
@@ -257,6 +271,15 @@ export let ChatSDKError;
|
|
|
257
271
|
ChatSDKError["WidgetUseOutsideOperatingHour"] = "WidgetUseOutsideOperatingHour";
|
|
258
272
|
})(ChatSDKError || (ChatSDKError = {}));
|
|
259
273
|
|
|
274
|
+
export let EnvironmentVersion;
|
|
275
|
+
|
|
276
|
+
(function (EnvironmentVersion) {
|
|
277
|
+
EnvironmentVersion["prod"] = "prod";
|
|
278
|
+
EnvironmentVersion["dogfood"] = "df";
|
|
279
|
+
EnvironmentVersion["int"] = "int";
|
|
280
|
+
EnvironmentVersion["test"] = "test";
|
|
281
|
+
})(EnvironmentVersion || (EnvironmentVersion = {}));
|
|
282
|
+
|
|
260
283
|
export class TranscriptConstants {}
|
|
261
284
|
|
|
262
285
|
_defineProperty(TranscriptConstants, "ChatTranscriptsBodyColor", "#F5F5F5");
|
|
@@ -277,4 +300,22 @@ _defineProperty(TranscriptConstants, "InternalMode", "internal");
|
|
|
277
300
|
|
|
278
301
|
_defineProperty(TranscriptConstants, "AgentDialogColor", "#2266E3");
|
|
279
302
|
|
|
280
|
-
_defineProperty(TranscriptConstants, "AgentFontColor", "white");
|
|
303
|
+
_defineProperty(TranscriptConstants, "AgentFontColor", "white");
|
|
304
|
+
|
|
305
|
+
export class AriaTelemetryConstants {}
|
|
306
|
+
|
|
307
|
+
_defineProperty(AriaTelemetryConstants, "GERMANY_ENDPOINT", "https://de.pipe.aria.microsoft.com/Collector/3.0/");
|
|
308
|
+
|
|
309
|
+
_defineProperty(AriaTelemetryConstants, "GCCH_ENDPOINT", "https://tb.pipe.aria.microsoft.com/Collector/3.0/");
|
|
310
|
+
|
|
311
|
+
_defineProperty(AriaTelemetryConstants, "DOD_ENDPOINT", "https://pf.pipe.aria.microsoft.com/Collector/3.0");
|
|
312
|
+
|
|
313
|
+
_defineProperty(AriaTelemetryConstants, "EUROPE_ENDPOINT", "https://eu-mobile.events.data.microsoft.com/Collector/3.0/");
|
|
314
|
+
|
|
315
|
+
_defineProperty(AriaTelemetryConstants, "MOONCAKE_ENDPOINT", "");
|
|
316
|
+
|
|
317
|
+
_defineProperty(AriaTelemetryConstants, "Public", "Public");
|
|
318
|
+
|
|
319
|
+
_defineProperty(AriaTelemetryConstants, "EU", "Europe");
|
|
320
|
+
|
|
321
|
+
_defineProperty(AriaTelemetryConstants, "lcwEUDomainNames", ["crm4.omnichannelengagementhub.com", "crm12.omnichannelengagementhub.com", "crm16.omnichannelengagementhub.com", "crm17.omnichannelengagementhub.com", "crm19.omnichannelengagementhub.com"]);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
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; }
|
|
2
|
+
|
|
3
|
+
import { BroadcastService } from "@microsoft/omnichannel-chat-components";
|
|
4
|
+
import { getWidgetCacheId } from "../../utils";
|
|
5
|
+
import { defaultClientDataStoreProvider } from "./defaultClientDataStoreProvider";
|
|
6
|
+
export class defaultCacheManager {}
|
|
7
|
+
|
|
8
|
+
_defineProperty(defaultCacheManager, "InternalCache", {});
|
|
9
|
+
|
|
10
|
+
export const registerBroadcastServiceForLocalStorage = (orgid, widgetId, widgetInstanceId) => {
|
|
11
|
+
const widgetCacheId = getWidgetCacheId(orgid, widgetId, widgetInstanceId);
|
|
12
|
+
BroadcastService.getMessageByEventName(widgetCacheId).subscribe(msg => {
|
|
13
|
+
try {
|
|
14
|
+
defaultClientDataStoreProvider().setData(widgetCacheId, JSON.stringify(msg.payload), "localStorage");
|
|
15
|
+
} catch (error) {
|
|
16
|
+
console.error("Error in setting data to localstorage", error);
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { inMemoryDataStore } from "./defaultInMemoryDataStore";
|
|
2
|
+
import { TelemetryHelper } from "../../telemetry/TelemetryHelper";
|
|
3
|
+
import { LogLevel, TelemetryEvent } from "../../telemetry/TelemetryConstants";
|
|
4
|
+
export const defaultClientDataStoreProvider = () => {
|
|
5
|
+
const isCookieAllowed = () => {
|
|
6
|
+
try {
|
|
7
|
+
localStorage;
|
|
8
|
+
sessionStorage;
|
|
9
|
+
return true;
|
|
10
|
+
} catch (error) {
|
|
11
|
+
console.error("Third party cookie blocked");
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const TtlInMs = 15 * 60 * 1000; // 15 mins
|
|
17
|
+
|
|
18
|
+
const dataStoreProvider = {
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
20
|
+
setData: (key, data, type) => {
|
|
21
|
+
if (isCookieAllowed()) {
|
|
22
|
+
try {
|
|
23
|
+
if (key) {
|
|
24
|
+
const now = new Date();
|
|
25
|
+
const item = {
|
|
26
|
+
data: data,
|
|
27
|
+
expiry: now.getTime() + TtlInMs
|
|
28
|
+
};
|
|
29
|
+
const strItem = JSON.stringify(item);
|
|
30
|
+
|
|
31
|
+
if (type === "localStorage") {
|
|
32
|
+
localStorage.setItem(key, strItem);
|
|
33
|
+
} else {
|
|
34
|
+
sessionStorage.setItem(key, strItem);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
} catch (error) {
|
|
38
|
+
TelemetryHelper.logConfigDataEvent(LogLevel.ERROR, {
|
|
39
|
+
Event: TelemetryEvent.ClientDataStoreProviderFailed,
|
|
40
|
+
ExceptionDetails: error,
|
|
41
|
+
Description: "Unable to store data in localStorage."
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
} else {
|
|
45
|
+
const dataToCache = {
|
|
46
|
+
key: key,
|
|
47
|
+
data: data,
|
|
48
|
+
type: type
|
|
49
|
+
};
|
|
50
|
+
parent.postMessage(dataToCache, "*");
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
54
|
+
getData: (key, type) => {
|
|
55
|
+
if (isCookieAllowed()) {
|
|
56
|
+
let item;
|
|
57
|
+
|
|
58
|
+
if (type === "localStorage") {
|
|
59
|
+
item = localStorage.getItem(key);
|
|
60
|
+
} else {
|
|
61
|
+
item = sessionStorage.getItem(key);
|
|
62
|
+
} //Return item if not expired
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
let itemInJson = undefined;
|
|
66
|
+
|
|
67
|
+
if (item !== null) {
|
|
68
|
+
itemInJson = JSON.parse(item);
|
|
69
|
+
const now = new Date(); // compare the expiry time of the item with the current time
|
|
70
|
+
|
|
71
|
+
if (now.getTime() > itemInJson.expiry) {
|
|
72
|
+
// If the item is expired, delete the item from storage
|
|
73
|
+
// and return null
|
|
74
|
+
localStorage.removeItem(key);
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return itemInJson.data;
|
|
79
|
+
}
|
|
80
|
+
} else {
|
|
81
|
+
// get data from in memory db when cookie is disabled
|
|
82
|
+
return inMemoryDataStore().getData(key);
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
86
|
+
removeData: (key, type) => {
|
|
87
|
+
if (isCookieAllowed()) {
|
|
88
|
+
if (key) {
|
|
89
|
+
if (type === "localStorage") {
|
|
90
|
+
return localStorage.removeItem(key);
|
|
91
|
+
} else {
|
|
92
|
+
return sessionStorage.removeItem(key);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
} else {
|
|
96
|
+
// get data from in memory db when cookie is disabled
|
|
97
|
+
return inMemoryDataStore().removeData(key);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
return dataStoreProvider;
|
|
102
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { LogLevel, TelemetryEvent } from "../../telemetry/TelemetryConstants";
|
|
2
|
+
import { TelemetryHelper } from "../../telemetry/TelemetryHelper";
|
|
3
|
+
import { defaultCacheManager } from "./defaultCacheManager";
|
|
4
|
+
export const defaultInitializeInMemoryDataStore = widgetId => {
|
|
5
|
+
try {
|
|
6
|
+
localStorage;
|
|
7
|
+
} catch (error) {
|
|
8
|
+
// Register below events when localStorage is not accessible
|
|
9
|
+
// Listening to event raised from client browser
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
11
|
+
window.addEventListener("message", function (e) {
|
|
12
|
+
try {
|
|
13
|
+
if (e.data.key) {
|
|
14
|
+
const browserData = e.data;
|
|
15
|
+
|
|
16
|
+
if (defaultCacheManager.InternalCache[browserData.key]) {
|
|
17
|
+
delete defaultCacheManager.InternalCache[browserData.key];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
defaultCacheManager.InternalCache[browserData.key] = browserData.data;
|
|
21
|
+
}
|
|
22
|
+
} catch (error) {
|
|
23
|
+
TelemetryHelper.logConfigDataEvent(LogLevel.ERROR, {
|
|
24
|
+
Event: TelemetryEvent.InMemoryDataStoreFailed,
|
|
25
|
+
ExceptionDetails: error,
|
|
26
|
+
Description: "Unable to register default in-memory cache."
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}); // send cache initialize message to client
|
|
30
|
+
|
|
31
|
+
if (defaultCacheManager.InternalCache === undefined || {}) {
|
|
32
|
+
parent.postMessage({
|
|
33
|
+
data: "cacheinitialize",
|
|
34
|
+
widgetId: widgetId
|
|
35
|
+
}, "*");
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
export const inMemoryDataStore = () => {
|
|
40
|
+
const dataStoreProvider = {
|
|
41
|
+
getData: key => {
|
|
42
|
+
if (defaultCacheManager.InternalCache && defaultCacheManager.InternalCache[key]) {
|
|
43
|
+
return defaultCacheManager.InternalCache[key];
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
47
|
+
setData: (key, data) => {
|
|
48
|
+
try {
|
|
49
|
+
defaultCacheManager.InternalCache[key] = data;
|
|
50
|
+
} catch (error) {
|
|
51
|
+
TelemetryHelper.logConfigDataEvent(LogLevel.ERROR, {
|
|
52
|
+
Event: TelemetryEvent.InMemoryDataStoreFailed,
|
|
53
|
+
ExceptionDetails: error,
|
|
54
|
+
Description: "Unable to set data in default in-memory cache."
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
removeData: key => {
|
|
59
|
+
try {
|
|
60
|
+
defaultCacheManager.InternalCache[key] = {};
|
|
61
|
+
} catch (error) {
|
|
62
|
+
TelemetryHelper.logConfigDataEvent(LogLevel.ERROR, {
|
|
63
|
+
Event: TelemetryEvent.InMemoryDataStoreFailed,
|
|
64
|
+
ExceptionDetails: error,
|
|
65
|
+
Description: "Unable to remove data from default in-memory cache."
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
return dataStoreProvider;
|
|
71
|
+
};
|