@microsoft/omnichannel-chat-widget 0.1.0-main.ae3aa42 → 0.1.0-main.b511ad6
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 +32 -0
- package/lib/cjs/common/Constants.js +16 -2
- package/lib/cjs/common/telemetry/TelemetryConstants.js +26 -3
- package/lib/cjs/common/telemetry/TelemetryManager.js +7 -1
- package/lib/cjs/common/telemetry/loggers/ariaTelemetryLogger.js +8 -9
- package/lib/cjs/common/telemetry/loggers/consoleLogger.js +6 -5
- package/lib/cjs/common/utils.js +63 -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 +0 -1
- package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +11 -2
- package/lib/cjs/components/headerstateful/HeaderStateful.js +2 -2
- 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/createAdapter.js +13 -1
- package/lib/cjs/components/livechatwidget/common/createMarkdown.js +31 -30
- package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +9 -15
- package/lib/cjs/components/livechatwidget/common/endChat.js +63 -16
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +20 -3
- package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +23 -15
- 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 +177 -67
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +206 -85
- 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 +80 -0
- package/lib/cjs/components/webchatcontainerstateful/common/mockchatsdk.js +2 -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/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/messageTimestampMiddleware.js +117 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +1 -0
- package/lib/cjs/contexts/common/ConversationState.js +3 -2
- package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +24 -21
- package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +3 -2
- package/lib/cjs/contexts/createReducer.js +16 -0
- package/lib/cjs/controller/componentController.js +3 -3
- package/lib/cjs/plugins/newMessageEventHandler.js +10 -13
- package/lib/esm/common/Constants.js +16 -2
- package/lib/esm/common/telemetry/TelemetryConstants.js +26 -3
- package/lib/esm/common/telemetry/TelemetryManager.js +6 -1
- package/lib/esm/common/telemetry/loggers/ariaTelemetryLogger.js +8 -6
- package/lib/esm/common/telemetry/loggers/consoleLogger.js +6 -5
- package/lib/esm/common/utils.js +44 -0
- 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 +0 -1
- package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +9 -3
- package/lib/esm/components/headerstateful/HeaderStateful.js +2 -2
- 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/createAdapter.js +12 -2
- package/lib/esm/components/livechatwidget/common/createMarkdown.js +31 -30
- package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +9 -15
- package/lib/esm/components/livechatwidget/common/endChat.js +61 -17
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +19 -5
- package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +23 -15
- 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 +172 -68
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +197 -87
- 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 +72 -0
- package/lib/esm/components/webchatcontainerstateful/common/mockchatsdk.js +2 -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/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/messageTimestampMiddleware.js +107 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +1 -0
- package/lib/esm/contexts/common/ConversationState.js +3 -2
- package/lib/esm/contexts/common/LiveChatWidgetActionType.js +24 -21
- package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +3 -2
- package/lib/esm/contexts/createReducer.js +16 -0
- package/lib/esm/controller/componentController.js +3 -3
- package/lib/esm/plugins/newMessageEventHandler.js +10 -12
- package/lib/types/common/Constants.d.ts +8 -1
- package/lib/types/common/interfaces/IContextDataStore.d.ts +1 -1
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +25 -5
- package/lib/types/common/telemetry/TelemetryHelper.d.ts +2 -1
- package/lib/types/common/telemetry/definitions/Payload.d.ts +12 -9
- package/lib/types/common/utils.d.ts +6 -1
- package/lib/types/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.d.ts +1 -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/endChat.d.ts +1 -1
- package/lib/types/components/livechatwidget/common/reconnectChatHelper.d.ts +5 -4
- package/lib/types/components/livechatwidget/common/setPostChatContextAndLoadSurvey.d.ts +1 -1
- 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/common/startProactiveChat.d.ts +1 -1
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +1 -0
- package/lib/types/components/reconnectchatpanestateful/interfaces/IReconnectChatPaneStatefulProps.d.ts +0 -1
- package/lib/types/components/webchatcontainerstateful/common/mockchatsdk.d.ts +1 -0
- package/lib/types/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.d.ts +4 -0
- package/lib/types/components/webchatcontainerstateful/interfaces/IWebChatContainerStatefulProps.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.d.ts +3 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.d.ts +1 -1
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/avatarMiddleware.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/messageTimestampMiddleware.d.ts +5 -0
- package/lib/types/contexts/common/ConversationState.d.ts +3 -2
- package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +2 -1
- package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +24 -21
- package/package.json +2 -2
|
@@ -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;
|
|
@@ -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
|
-
|
|
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
|
-
|
|
30
|
-
|
|
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
|
-
|
|
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
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
-
|
|
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 (
|
|
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(``, 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
|
-
}
|
|
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
|
|
|
@@ -274,18 +274,6 @@ const dummyDefaultProps = {
|
|
|
274
274
|
width: "50px",
|
|
275
275
|
fontSize: "18px"
|
|
276
276
|
},
|
|
277
|
-
currentCallTimerStyleProps: {
|
|
278
|
-
borderRadius: "2px",
|
|
279
|
-
margin: "1px",
|
|
280
|
-
color: "#FFFFFF",
|
|
281
|
-
paddingTop: "18px",
|
|
282
|
-
fontSize: 12,
|
|
283
|
-
fontFamily: "Segoe UI, Arial, sans-serif",
|
|
284
|
-
backgroundColor: "darkgrey",
|
|
285
|
-
height: "45px",
|
|
286
|
-
width: "50px",
|
|
287
|
-
textAlign: "center"
|
|
288
|
-
},
|
|
289
277
|
videoTileStyleProps: {
|
|
290
278
|
width: "100%",
|
|
291
279
|
marginLeft: "auto",
|
|
@@ -349,7 +337,9 @@ const dummyDefaultProps = {
|
|
|
349
337
|
hideChatTextContainer: false,
|
|
350
338
|
hideChatSubtitle: false,
|
|
351
339
|
hideChatTitle: false,
|
|
352
|
-
hideNotificationBubble: true
|
|
340
|
+
hideNotificationBubble: true,
|
|
341
|
+
unreadMessageString: "new messages",
|
|
342
|
+
largeUnreadMessageString: "99+"
|
|
353
343
|
},
|
|
354
344
|
styleProps: {
|
|
355
345
|
generalStyleProps: {
|
|
@@ -1444,7 +1434,6 @@ const dummyDefaultProps = {
|
|
|
1444
1434
|
startNewChatButtonClassName: undefined
|
|
1445
1435
|
}
|
|
1446
1436
|
},
|
|
1447
|
-
authClientFunction: undefined,
|
|
1448
1437
|
isReconnectEnabled: undefined,
|
|
1449
1438
|
reconnectId: undefined,
|
|
1450
1439
|
redirectInSameWindow: undefined
|
|
@@ -1709,8 +1698,13 @@ const dummyDefaultProps = {
|
|
|
1709
1698
|
MIDDLEWARE_MESSAGE_RETRY: "Retry",
|
|
1710
1699
|
PRECHAT_REQUIRED_FIELD_MISSING_MESSAGE: "{0} field is required",
|
|
1711
1700
|
MARKDOWN_EXTERNAL_LINK_ALT: "Opens in a new window; external."
|
|
1701
|
+
},
|
|
1702
|
+
botMagicCode: {
|
|
1703
|
+
disabled: false,
|
|
1704
|
+
fwdUrl: ""
|
|
1712
1705
|
}
|
|
1713
1706
|
},
|
|
1714
|
-
telemetryConfig: undefined
|
|
1707
|
+
telemetryConfig: undefined,
|
|
1708
|
+
getAuthToken: undefined
|
|
1715
1709
|
};
|
|
1716
1710
|
exports.dummyDefaultProps = dummyDefaultProps;
|
|
@@ -23,20 +23,39 @@ var _PostChatSurveyMode = require("../../postchatsurveypanestateful/enums/PostCh
|
|
|
23
23
|
|
|
24
24
|
var _Constants = require("../../../common/Constants");
|
|
25
25
|
|
|
26
|
+
var _utils = require("../../../common/utils");
|
|
27
|
+
|
|
26
28
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
27
29
|
const prepareEndChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state) => {
|
|
28
|
-
var _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _state$domainStates$l4;
|
|
30
|
+
var _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _state$domainStates$l4, _conversationDetails;
|
|
29
31
|
|
|
30
32
|
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;
|
|
31
|
-
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;
|
|
32
|
-
|
|
33
|
+
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; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
34
|
+
|
|
35
|
+
let conversationDetails = undefined;
|
|
36
|
+
|
|
37
|
+
try {
|
|
38
|
+
conversationDetails = await chatSDK.getConversationDetails();
|
|
39
|
+
} catch (erorr) {
|
|
40
|
+
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
41
|
+
Event: _TelemetryConstants.TelemetryEvent.GetConversationDetailsException,
|
|
42
|
+
ExceptionDetails: {
|
|
43
|
+
exception: `Failed to get conversation details: ${erorr}`
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
33
47
|
|
|
34
|
-
if (isPostChatEnabled === "true" && (conversationDetails === null ||
|
|
48
|
+
if (isPostChatEnabled === "true" && ((_conversationDetails = conversationDetails) === null || _conversationDetails === void 0 ? void 0 : _conversationDetails.canRenderPostChat) === _Constants.Constants.truePascal) {
|
|
35
49
|
const skipEndChatSDK = false;
|
|
36
50
|
const skipCloseChat = true;
|
|
37
|
-
await endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, skipEndChatSDK, skipCloseChat);
|
|
51
|
+
await endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, skipEndChatSDK, skipCloseChat, true);
|
|
38
52
|
|
|
39
53
|
if (postChatSurveyMode === _PostChatSurveyMode.PostChatSurveyMode.Embed) {
|
|
54
|
+
dispatch({
|
|
55
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
56
|
+
payload: _ConversationState.ConversationState.PostchatLoading
|
|
57
|
+
});
|
|
58
|
+
await (0, _utils.addDelayInMs)(_Constants.Constants.PostChatLoadingDurationInMs);
|
|
40
59
|
const loadPostChatEvent = {
|
|
41
60
|
eventName: _TelemetryConstants.BroadcastEvent.LoadPostChatSurvey
|
|
42
61
|
};
|
|
@@ -48,15 +67,17 @@ const prepareEndChat = async (props, chatSDK, setAdapter, setWebChatStyles, disp
|
|
|
48
67
|
payload: _ConversationState.ConversationState.InActive
|
|
49
68
|
});
|
|
50
69
|
}
|
|
51
|
-
|
|
52
|
-
|
|
70
|
+
|
|
71
|
+
return;
|
|
53
72
|
}
|
|
73
|
+
|
|
74
|
+
await endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, false, false, true);
|
|
54
75
|
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
55
76
|
|
|
56
77
|
|
|
57
78
|
exports.prepareEndChat = prepareEndChat;
|
|
58
79
|
|
|
59
|
-
const endChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, skipEndChatSDK, skipCloseChat) => {
|
|
80
|
+
const endChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, skipEndChatSDK, skipCloseChat, postMessageToOtherTab) => {
|
|
60
81
|
if (!skipEndChatSDK) {
|
|
61
82
|
try {
|
|
62
83
|
_TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
@@ -71,8 +92,24 @@ const endChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, a
|
|
|
71
92
|
exception: ex
|
|
72
93
|
}
|
|
73
94
|
});
|
|
95
|
+
|
|
96
|
+
postMessageToOtherTab = false;
|
|
74
97
|
}
|
|
75
|
-
}
|
|
98
|
+
} // Need to clear these states immediately when chat ended from OC.
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
dispatch({
|
|
102
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CUSTOM_CONTEXT,
|
|
103
|
+
payload: undefined
|
|
104
|
+
});
|
|
105
|
+
dispatch({
|
|
106
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CHAT_TOKEN,
|
|
107
|
+
payload: undefined
|
|
108
|
+
});
|
|
109
|
+
dispatch({
|
|
110
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
|
|
111
|
+
payload: undefined
|
|
112
|
+
});
|
|
76
113
|
|
|
77
114
|
if (!skipCloseChat) {
|
|
78
115
|
try {
|
|
@@ -101,17 +138,27 @@ const endChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, a
|
|
|
101
138
|
payload: null
|
|
102
139
|
});
|
|
103
140
|
dispatch({
|
|
104
|
-
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.
|
|
105
|
-
payload:
|
|
141
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_UNREAD_MESSAGE_COUNT,
|
|
142
|
+
payload: 0
|
|
106
143
|
});
|
|
107
144
|
dispatch({
|
|
108
|
-
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.
|
|
109
|
-
payload:
|
|
145
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_PROACTIVE_CHAT_PARAMS,
|
|
146
|
+
payload: {
|
|
147
|
+
proactiveChatBodyTitle: "",
|
|
148
|
+
proactiveChatEnablePrechat: false,
|
|
149
|
+
proactiveChatInNewWindow: false
|
|
150
|
+
}
|
|
110
151
|
});
|
|
111
152
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
153
|
+
if (postMessageToOtherTab) {
|
|
154
|
+
var _chatSDK$omnichannelC, _chatSDK$omnichannelC2;
|
|
155
|
+
|
|
156
|
+
const endChatEventName = (0, _utils.getWidgetEndChatEventName)(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC === void 0 ? void 0 : _chatSDK$omnichannelC.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC2 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC2 === void 0 ? void 0 : _chatSDK$omnichannelC2.widgetId);
|
|
157
|
+
|
|
158
|
+
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
159
|
+
eventName: endChatEventName
|
|
160
|
+
});
|
|
161
|
+
}
|
|
115
162
|
} catch (error) {
|
|
116
163
|
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
117
164
|
Event: _TelemetryConstants.TelemetryEvent.CloseChatMethodException,
|
|
@@ -63,11 +63,17 @@ var _preProcessingMiddleware = _interopRequireDefault(require("../../webchatcont
|
|
|
63
63
|
|
|
64
64
|
var _sanitizationMiddleware = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/sanitizationMiddleware"));
|
|
65
65
|
|
|
66
|
+
var _cardActionMiddleware = require("../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware");
|
|
67
|
+
|
|
68
|
+
var _messageTimestampMiddleware = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware"));
|
|
69
|
+
|
|
70
|
+
var _Constants = require("../../../common/Constants");
|
|
71
|
+
|
|
66
72
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
67
73
|
|
|
68
74
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
69
75
|
const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatStyles) => {
|
|
70
|
-
var _props$webChatContain, _props$webChatContain2, _props$webChatContain3, _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _state$domainStates$l4, _state$domainStates$l8, _state$domainStates$l9, _props$webChatContain7, _props$webChatContain8, _state$domainStates$r, _state$domainStates$r2, _props$webChatContain9, _props$webChatContain10, _state$domainStates$r3, _state$domainStates$r4, _props$webChatContain11, _props$webChatContain12, _defaultWebChatContai, _props$webChatContain13, _props$webChatContain14, _props$webChatContain15, _props$webChatContain16, _state$domainStates$r5, _state$domainStates$r6, _props$webChatContain17, _props$webChatContain18, _defaultWebChatContai2, _props$webChatContain19, _props$webChatContain20, _defaultWebChatContai3, _props$webChatContain21;
|
|
76
|
+
var _props$webChatContain, _props$webChatContain2, _props$webChatContain3, _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _state$domainStates$l4, _state$domainStates$l8, _state$domainStates$l9, _props$webChatContain7, _props$webChatContain8, _state$domainStates$r, _state$domainStates$r2, _props$webChatContain9, _props$webChatContain10, _state$domainStates$r3, _state$domainStates$r4, _props$webChatContain11, _props$webChatContain12, _defaultWebChatContai, _props$webChatContain13, _props$webChatContain14, _props$webChatContain15, _props$webChatContain16, _state$domainStates$r5, _state$domainStates$r6, _props$webChatContain17, _props$webChatContain18, _defaultWebChatContai2, _props$webChatContain19, _props$webChatContain20, _defaultWebChatContai3, _props$webChatContain21, _props$webChatContain22;
|
|
71
77
|
|
|
72
78
|
const localizedTexts = { ..._defaultMiddlewareLocalizedTexts.defaultMiddlewareLocalizedTexts,
|
|
73
79
|
...((_props$webChatContain = props.webChatContainerProps) === null || _props$webChatContain === void 0 ? void 0 : _props$webChatContain.localizedTexts)
|
|
@@ -101,6 +107,12 @@ const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatStyles)
|
|
|
101
107
|
|
|
102
108
|
if (isPostChatEnabled === "true") {
|
|
103
109
|
if (postChatSurveyMode === _PostChatSurveyMode.PostChatSurveyMode.Embed) {
|
|
110
|
+
_WebChatStoreLoader.WebChatStoreLoader.store = null;
|
|
111
|
+
dispatch({
|
|
112
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
113
|
+
payload: _ConversationState.ConversationState.PostchatLoading
|
|
114
|
+
});
|
|
115
|
+
await (0, _utils.addDelayInMs)(_Constants.Constants.PostChatLoadingDurationInMs);
|
|
104
116
|
const loadPostChatEvent = {
|
|
105
117
|
eventName: _TelemetryConstants.BroadcastEvent.LoadPostChatSurvey
|
|
106
118
|
};
|
|
@@ -123,10 +135,14 @@ const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatStyles)
|
|
|
123
135
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CHAT_TOKEN,
|
|
124
136
|
payload: undefined
|
|
125
137
|
});
|
|
138
|
+
dispatch({
|
|
139
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
|
|
140
|
+
payload: undefined
|
|
141
|
+
});
|
|
126
142
|
};
|
|
127
143
|
|
|
128
144
|
webChatStore = (0, _botframeworkWebchat.createStore)({}, //initial state
|
|
129
|
-
_preProcessingMiddleware.default, _attachmentProcessingMiddleware.default, (0, _attachmentUploadValidatorMiddleware.default)((_state$domainStates$l5 = state.domainStates.liveChatConfig) === null || _state$domainStates$l5 === void 0 ? void 0 : _state$domainStates$l5.allowedFileExtensions, (_state$domainStates$l6 = state.domainStates.liveChatConfig) === null || _state$domainStates$l6 === void 0 ? void 0 : _state$domainStates$l6.maxUploadFileSize, localizedTexts), _channelDataMiddleware.default, (0, _conversationEndMiddleware.default)(conversationEndCallback), (0, _dataMaskingMiddleware.default)((_state$domainStates$l7 = state.domainStates.liveChatConfig) === null || _state$domainStates$l7 === void 0 ? void 0 : _state$domainStates$l7.DataMaskingInfo), _gifUploadMiddleware.default, _htmlPlayerMiddleware.default, _htmlTextMiddleware.default, (0, _maxMessageSizeValidator.default)(localizedTexts), _sanitizationMiddleware.default, // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
145
|
+
_preProcessingMiddleware.default, _attachmentProcessingMiddleware.default, (0, _attachmentUploadValidatorMiddleware.default)((_state$domainStates$l5 = state.domainStates.liveChatConfig) === null || _state$domainStates$l5 === void 0 ? void 0 : _state$domainStates$l5.allowedFileExtensions, (_state$domainStates$l6 = state.domainStates.liveChatConfig) === null || _state$domainStates$l6 === void 0 ? void 0 : _state$domainStates$l6.maxUploadFileSize, localizedTexts), _channelDataMiddleware.default, (0, _conversationEndMiddleware.default)(conversationEndCallback), (0, _dataMaskingMiddleware.default)((_state$domainStates$l7 = state.domainStates.liveChatConfig) === null || _state$domainStates$l7 === void 0 ? void 0 : _state$domainStates$l7.DataMaskingInfo), _messageTimestampMiddleware.default, _gifUploadMiddleware.default, _htmlPlayerMiddleware.default, _htmlTextMiddleware.default, (0, _maxMessageSizeValidator.default)(localizedTexts), _sanitizationMiddleware.default, // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
130
146
|
...(((_props$webChatContain6 = props.webChatContainerProps) === null || _props$webChatContain6 === void 0 ? void 0 : _props$webChatContain6.storeMiddlewares) ?? []));
|
|
131
147
|
_WebChatStoreLoader.WebChatStoreLoader.store = webChatStore;
|
|
132
148
|
} // Initialize the remaining Web Chat props
|
|
@@ -144,7 +160,8 @@ const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatStyles)
|
|
|
144
160
|
groupActivitiesMiddleware: (_props$webChatContain17 = props.webChatContainerProps) !== null && _props$webChatContain17 !== void 0 && (_props$webChatContain18 = _props$webChatContain17.renderingMiddlewareProps) !== null && _props$webChatContain18 !== void 0 && _props$webChatContain18.disableGroupActivitiesMiddleware ? undefined : (_defaultWebChatContai2 = _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.webChatProps) === null || _defaultWebChatContai2 === void 0 ? void 0 : _defaultWebChatContai2.groupActivitiesMiddleware,
|
|
145
161
|
typingIndicatorMiddleware: (_props$webChatContain19 = props.webChatContainerProps) !== null && _props$webChatContain19 !== void 0 && (_props$webChatContain20 = _props$webChatContain19.renderingMiddlewareProps) !== null && _props$webChatContain20 !== void 0 && _props$webChatContain20.disableTypingIndicatorMiddleware ? undefined : (_defaultWebChatContai3 = _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.webChatProps) === null || _defaultWebChatContai3 === void 0 ? void 0 : _defaultWebChatContai3.typingIndicatorMiddleware,
|
|
146
162
|
onTelemetry: (0, _WebChatLogger.createWebChatTelemetry)(),
|
|
147
|
-
|
|
163
|
+
cardActionMiddleware: (0, _cardActionMiddleware.createCardActionMiddleware)(((_props$webChatContain21 = props.webChatContainerProps) === null || _props$webChatContain21 === void 0 ? void 0 : _props$webChatContain21.botMagicCode) || undefined),
|
|
164
|
+
...((_props$webChatContain22 = props.webChatContainerProps) === null || _props$webChatContain22 === void 0 ? void 0 : _props$webChatContain22.webChatProps)
|
|
148
165
|
};
|
|
149
166
|
return webChatProps;
|
|
150
167
|
};
|
|
@@ -44,9 +44,17 @@ const getChatReconnectContext = async (chatSDK, reconnectId) => {
|
|
|
44
44
|
exports.getChatReconnectContext = getChatReconnectContext;
|
|
45
45
|
|
|
46
46
|
const getReconnectIdForAuthenticatedChat = async (props, chatSDK) => {
|
|
47
|
-
var _props$
|
|
47
|
+
var _props$chatConfig, _props$reconnectChatP;
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
let authClientFunction = undefined;
|
|
50
|
+
|
|
51
|
+
if ((_props$chatConfig = props.chatConfig) !== null && _props$chatConfig !== void 0 && _props$chatConfig.LiveChatConfigAuthSettings) {
|
|
52
|
+
var _props$chatConfig2, _props$chatConfig2$Li;
|
|
53
|
+
|
|
54
|
+
authClientFunction = ((_props$chatConfig2 = props.chatConfig) === null || _props$chatConfig2 === void 0 ? void 0 : (_props$chatConfig2$Li = _props$chatConfig2.LiveChatConfigAuthSettings) === null || _props$chatConfig2$Li === void 0 ? void 0 : _props$chatConfig2$Li.msdyn_javascriptclientfunction) ?? undefined;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if ((_props$reconnectChatP = props.reconnectChatPaneProps) !== null && _props$reconnectChatP !== void 0 && _props$reconnectChatP.isReconnectEnabled && authClientFunction // TODO: Implement this after storage is in place
|
|
50
58
|
|
|
51
59
|
/* && !isLoadWithState() */
|
|
52
60
|
) {
|
|
@@ -63,31 +71,31 @@ const getReconnectIdForAuthenticatedChat = async (props, chatSDK) => {
|
|
|
63
71
|
|
|
64
72
|
exports.getReconnectIdForAuthenticatedChat = getReconnectIdForAuthenticatedChat;
|
|
65
73
|
|
|
66
|
-
const handleUnauthenticatedReconnectChat = async (chatSDK, dispatch, setAdapter, reconnectId, initStartChat, redirectInSameWindow) => {
|
|
74
|
+
const handleUnauthenticatedReconnectChat = async (chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, reconnectId, initStartChat, redirectInSameWindow) => {
|
|
67
75
|
const reconnectAvailabilityResponse = await getChatReconnectContext(chatSDK, reconnectId);
|
|
68
76
|
|
|
69
77
|
if (shouldRedirectOrStartNewChat(reconnectAvailabilityResponse)) {
|
|
70
|
-
await redirectOrStartNewChat(reconnectAvailabilityResponse, chatSDK, dispatch, setAdapter, initStartChat, redirectInSameWindow);
|
|
78
|
+
await redirectOrStartNewChat(reconnectAvailabilityResponse, chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, initStartChat, redirectInSameWindow);
|
|
71
79
|
} else {
|
|
72
|
-
await setReconnectIdAndStartChat(chatSDK, dispatch, setAdapter, reconnectId, initStartChat);
|
|
80
|
+
await setReconnectIdAndStartChat(chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, reconnectId, initStartChat);
|
|
73
81
|
}
|
|
74
82
|
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
75
83
|
|
|
76
84
|
|
|
77
85
|
exports.handleUnauthenticatedReconnectChat = handleUnauthenticatedReconnectChat;
|
|
78
86
|
|
|
79
|
-
const startUnauthenticatedReconnectChat = async (chatSDK, dispatch, setAdapter, reconnectId, initStartChat) => {
|
|
87
|
+
const startUnauthenticatedReconnectChat = async (chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, reconnectId, initStartChat) => {
|
|
80
88
|
const reconnectAvailabilityResponse = await getChatReconnectContext(chatSDK, reconnectId);
|
|
81
89
|
|
|
82
90
|
if (!shouldRedirectOrStartNewChat(reconnectAvailabilityResponse)) {
|
|
83
|
-
await setReconnectIdAndStartChat(chatSDK, dispatch, setAdapter, reconnectId, initStartChat);
|
|
91
|
+
await setReconnectIdAndStartChat(chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, reconnectId, initStartChat);
|
|
84
92
|
}
|
|
85
93
|
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
86
94
|
|
|
87
95
|
|
|
88
96
|
exports.startUnauthenticatedReconnectChat = startUnauthenticatedReconnectChat;
|
|
89
97
|
|
|
90
|
-
const setReconnectIdAndStartChat = async (chatSDK, dispatch, setAdapter, reconnectId, initStartChat) => {
|
|
98
|
+
const setReconnectIdAndStartChat = async (chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, reconnectId, initStartChat) => {
|
|
91
99
|
const startUnauthenticatedReconnectChat = {
|
|
92
100
|
eventName: _TelemetryConstants.BroadcastEvent.StartUnauthenticatedReconnectChat
|
|
93
101
|
};
|
|
@@ -105,7 +113,7 @@ const setReconnectIdAndStartChat = async (chatSDK, dispatch, setAdapter, reconne
|
|
|
105
113
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
106
114
|
payload: _ConversationState.ConversationState.Loading
|
|
107
115
|
});
|
|
108
|
-
await initStartChat(chatSDK, dispatch, setAdapter, optionalParams);
|
|
116
|
+
await initStartChat(chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, optionalParams);
|
|
109
117
|
};
|
|
110
118
|
|
|
111
119
|
const redirectPage = (redirectURL, redirectInSameWindow) => {
|
|
@@ -128,7 +136,7 @@ const shouldRedirectOrStartNewChat = reconnectAvailabilityResponse => {
|
|
|
128
136
|
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
129
137
|
|
|
130
138
|
|
|
131
|
-
const startNewChatEmptyRedirectionUrl = async (chatSDK, dispatch, setAdapter, initStartChat) => {
|
|
139
|
+
const startNewChatEmptyRedirectionUrl = async (chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, initStartChat) => {
|
|
132
140
|
const startUnauthenticatedReconnectChat = {
|
|
133
141
|
eventName: _TelemetryConstants.BroadcastEvent.StartUnauthenticatedReconnectChat
|
|
134
142
|
};
|
|
@@ -153,26 +161,26 @@ const startNewChatEmptyRedirectionUrl = async (chatSDK, dispatch, setAdapter, in
|
|
|
153
161
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
154
162
|
payload: _ConversationState.ConversationState.Loading
|
|
155
163
|
});
|
|
156
|
-
await initStartChat(chatSDK, dispatch, setAdapter);
|
|
164
|
+
await initStartChat(chatSDK, chatConfig, getAuthToken, dispatch, setAdapter);
|
|
157
165
|
}
|
|
158
166
|
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
159
167
|
|
|
160
168
|
|
|
161
|
-
const handleRedirectUnauthenticatedReconnectChat = async (chatSDK, dispatch, setAdapter, initStartChat, reconnectId, redirectInSameWindow) => {
|
|
169
|
+
const handleRedirectUnauthenticatedReconnectChat = async (chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, initStartChat, reconnectId, redirectInSameWindow) => {
|
|
162
170
|
const reconnectAvailabilityResponse = await getChatReconnectContext(chatSDK, reconnectId);
|
|
163
171
|
|
|
164
172
|
if (shouldRedirectOrStartNewChat(reconnectAvailabilityResponse)) {
|
|
165
|
-
await redirectOrStartNewChat(reconnectAvailabilityResponse, chatSDK, dispatch, setAdapter, initStartChat, redirectInSameWindow);
|
|
173
|
+
await redirectOrStartNewChat(reconnectAvailabilityResponse, chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, initStartChat, redirectInSameWindow);
|
|
166
174
|
}
|
|
167
175
|
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
168
176
|
|
|
169
177
|
|
|
170
178
|
exports.handleRedirectUnauthenticatedReconnectChat = handleRedirectUnauthenticatedReconnectChat;
|
|
171
179
|
|
|
172
|
-
const redirectOrStartNewChat = async (reconnectAvailabilityResponse, chatSDK, dispatch, setAdapter, initStartChat, redirectInSameWindow) => {
|
|
180
|
+
const redirectOrStartNewChat = async (reconnectAvailabilityResponse, chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, initStartChat, redirectInSameWindow) => {
|
|
173
181
|
if (reconnectAvailabilityResponse.redirectURL) {
|
|
174
182
|
redirectPage(reconnectAvailabilityResponse.redirectURL, redirectInSameWindow);
|
|
175
183
|
} else {
|
|
176
|
-
await startNewChatEmptyRedirectionUrl(chatSDK, dispatch, setAdapter, initStartChat);
|
|
184
|
+
await startNewChatEmptyRedirectionUrl(chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, initStartChat);
|
|
177
185
|
}
|
|
178
186
|
};
|
|
@@ -43,10 +43,6 @@ const setPostChatContextAndLoadSurvey = async (chatSDK, dispatch, persistedChat)
|
|
|
43
43
|
|
|
44
44
|
|
|
45
45
|
_omnichannelChatComponents.BroadcastService.getMessageByEventName("LoadPostChatSurvey").subscribe(msg => {
|
|
46
|
-
dispatch({
|
|
47
|
-
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
48
|
-
payload: _ConversationState.ConversationState.Loading
|
|
49
|
-
});
|
|
50
46
|
dispatch({
|
|
51
47
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
52
48
|
payload: _ConversationState.ConversationState.Postchat
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.shareObservable = shareObservable;
|
|
7
|
+
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9
|
+
function shareObservable(observable) {
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
11
|
+
let observers = []; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12
|
+
|
|
13
|
+
let subscription; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
14
|
+
|
|
15
|
+
return new window.Observable(observer => {
|
|
16
|
+
if (!subscription) {
|
|
17
|
+
subscription = observable.subscribe({
|
|
18
|
+
complete() {
|
|
19
|
+
observers.forEach(observer => observer.complete());
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
23
|
+
error(err) {
|
|
24
|
+
observers.forEach(observer => observer.error(err));
|
|
25
|
+
},
|
|
26
|
+
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
28
|
+
next(value) {
|
|
29
|
+
observers.forEach(observer => observer.next(value));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
observers.push(observer);
|
|
36
|
+
return () => {
|
|
37
|
+
observers = observers.filter(o => o !== observer);
|
|
38
|
+
|
|
39
|
+
if (!observers.length) {
|
|
40
|
+
subscription.unsubscribe();
|
|
41
|
+
subscription = null;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
});
|
|
45
|
+
}
|