@microsoft/omnichannel-chat-widget 1.7.3-main.112d01b → 1.7.3-main.34ea4da

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/lib/cjs/common/Constants.js +1 -0
  2. package/lib/cjs/common/telemetry/TelemetryConstants.js +3 -0
  3. package/lib/cjs/components/footerstateful/FooterStateful.js +14 -3
  4. package/lib/cjs/components/livechatwidget/LiveChatWidget.js +6 -1
  5. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +15 -6
  6. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/HiddenAdaptiveCardActivitySubscriber.js +77 -0
  7. package/lib/cjs/components/livechatwidget/common/chatDisconnectHelper.js +2 -2
  8. package/lib/cjs/components/livechatwidget/common/createAdapter.js +15 -2
  9. package/lib/cjs/components/livechatwidget/common/createInternetConnectionChangeHandler.js +6 -2
  10. package/lib/cjs/components/livechatwidget/common/createMarkdown.js +2 -2
  11. package/lib/cjs/components/livechatwidget/common/endChat.js +20 -5
  12. package/lib/cjs/components/livechatwidget/common/getMockChatSDKIfApplicable.js +26 -0
  13. package/lib/cjs/components/livechatwidget/common/helpers/markdownHelper.js +23 -0
  14. package/lib/cjs/components/livechatwidget/common/overridePropsOnMockIfApplicable.js +41 -0
  15. package/lib/cjs/components/livechatwidget/common/persistentChatHelper.js +2 -1
  16. package/lib/cjs/components/livechatwidget/common/startChat.js +37 -28
  17. package/lib/cjs/components/livechatwidget/common/startChatErrorHandler.js +6 -6
  18. package/lib/cjs/components/livechatwidget/common/updateSessionDataForTelemetry.js +8 -3
  19. package/lib/cjs/components/livechatwidget/interfaces/IBotAuthActivitySubscriberOptionalParams.js +1 -0
  20. package/lib/cjs/components/livechatwidget/interfaces/IMockProps.js +7 -0
  21. package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +30 -0
  22. package/lib/cjs/components/webchatcontainerstateful/common/DemoChatAdapter.js +87 -0
  23. package/lib/cjs/components/webchatcontainerstateful/common/DemoChatSDK.js +17 -0
  24. package/lib/cjs/components/webchatcontainerstateful/common/DesignerChatAdapter.js +41 -0
  25. package/lib/cjs/components/webchatcontainerstateful/common/DesignerChatSDK.js +17 -0
  26. package/lib/cjs/components/webchatcontainerstateful/common/MockBotCardCommandType.js +14 -0
  27. package/lib/cjs/components/webchatcontainerstateful/common/MockBotCommand.js +19 -0
  28. package/lib/cjs/components/webchatcontainerstateful/common/mockchatsdk.js +3 -0
  29. package/lib/cjs/components/webchatcontainerstateful/common/utils/attachmentActivityUtils.js +71 -0
  30. package/lib/cjs/components/webchatcontainerstateful/common/utils/chatAdapterUtils.js +90 -0
  31. package/lib/cjs/components/webchatcontainerstateful/interfaces/IBotAuthConfig.js +1 -0
  32. package/lib/cjs/plugins/createChatTranscript.js +84 -0
  33. package/lib/cjs/plugins/newMessageEventHandler.js +4 -2
  34. package/lib/esm/common/Constants.js +1 -0
  35. package/lib/esm/common/telemetry/TelemetryConstants.js +3 -0
  36. package/lib/esm/components/footerstateful/FooterStateful.js +12 -3
  37. package/lib/esm/components/livechatwidget/LiveChatWidget.js +6 -1
  38. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +15 -6
  39. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/HiddenAdaptiveCardActivitySubscriber.js +70 -0
  40. package/lib/esm/components/livechatwidget/common/chatDisconnectHelper.js +3 -2
  41. package/lib/esm/components/livechatwidget/common/createAdapter.js +14 -2
  42. package/lib/esm/components/livechatwidget/common/createInternetConnectionChangeHandler.js +6 -2
  43. package/lib/esm/components/livechatwidget/common/createMarkdown.js +2 -2
  44. package/lib/esm/components/livechatwidget/common/endChat.js +20 -5
  45. package/lib/esm/components/livechatwidget/common/getMockChatSDKIfApplicable.js +20 -0
  46. package/lib/esm/components/livechatwidget/common/helpers/markdownHelper.js +15 -0
  47. package/lib/esm/components/livechatwidget/common/overridePropsOnMockIfApplicable.js +34 -0
  48. package/lib/esm/components/livechatwidget/common/persistentChatHelper.js +2 -1
  49. package/lib/esm/components/livechatwidget/common/startChat.js +37 -28
  50. package/lib/esm/components/livechatwidget/common/startChatErrorHandler.js +7 -7
  51. package/lib/esm/components/livechatwidget/common/updateSessionDataForTelemetry.js +7 -2
  52. package/lib/esm/components/livechatwidget/interfaces/IBotAuthActivitySubscriberOptionalParams.js +1 -0
  53. package/lib/esm/components/livechatwidget/interfaces/IMockProps.js +6 -0
  54. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +31 -1
  55. package/lib/esm/components/webchatcontainerstateful/common/DemoChatAdapter.js +79 -0
  56. package/lib/esm/components/webchatcontainerstateful/common/DemoChatSDK.js +10 -0
  57. package/lib/esm/components/webchatcontainerstateful/common/DesignerChatAdapter.js +33 -0
  58. package/lib/esm/components/webchatcontainerstateful/common/DesignerChatSDK.js +10 -0
  59. package/lib/esm/components/webchatcontainerstateful/common/MockBotCardCommandType.js +7 -0
  60. package/lib/esm/components/webchatcontainerstateful/common/MockBotCommand.js +12 -0
  61. package/lib/esm/components/webchatcontainerstateful/common/mockchatsdk.js +3 -0
  62. package/lib/esm/components/webchatcontainerstateful/common/utils/attachmentActivityUtils.js +61 -0
  63. package/lib/esm/components/webchatcontainerstateful/common/utils/chatAdapterUtils.js +77 -0
  64. package/lib/esm/components/webchatcontainerstateful/interfaces/IBotAuthConfig.js +1 -0
  65. package/lib/esm/plugins/createChatTranscript.js +84 -0
  66. package/lib/esm/plugins/newMessageEventHandler.js +4 -2
  67. package/lib/types/common/Constants.d.ts +1 -0
  68. package/lib/types/common/telemetry/TelemetryConstants.d.ts +4 -1
  69. package/lib/types/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.d.ts +4 -1
  70. package/lib/types/components/livechatwidget/common/ActivitySubscriber/HiddenAdaptiveCardActivitySubscriber.d.ts +7 -0
  71. package/lib/types/components/livechatwidget/common/createAdapter.d.ts +2 -1
  72. package/lib/types/components/livechatwidget/common/getMockChatSDKIfApplicable.d.ts +1 -0
  73. package/lib/types/components/livechatwidget/common/helpers/markdownHelper.d.ts +2 -0
  74. package/lib/types/components/livechatwidget/common/overridePropsOnMockIfApplicable.d.ts +3 -0
  75. package/lib/types/components/livechatwidget/common/updateSessionDataForTelemetry.d.ts +1 -1
  76. package/lib/types/components/livechatwidget/interfaces/IBotAuthActivitySubscriberOptionalParams.d.ts +4 -0
  77. package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +2 -0
  78. package/lib/types/components/livechatwidget/interfaces/IMockProps.d.ts +8 -0
  79. package/lib/types/components/webchatcontainerstateful/common/DemoChatAdapter.d.ts +10 -0
  80. package/lib/types/components/webchatcontainerstateful/common/DemoChatSDK.d.ts +6 -0
  81. package/lib/types/components/webchatcontainerstateful/common/DesignerChatAdapter.d.ts +8 -0
  82. package/lib/types/components/webchatcontainerstateful/common/DesignerChatSDK.d.ts +6 -0
  83. package/lib/types/components/webchatcontainerstateful/common/MockBotCardCommandType.d.ts +6 -0
  84. package/lib/types/components/webchatcontainerstateful/common/MockBotCommand.d.ts +11 -0
  85. package/lib/types/components/webchatcontainerstateful/common/mockadapter.d.ts +2 -1
  86. package/lib/types/components/webchatcontainerstateful/common/mockchatsdk.d.ts +6 -0
  87. package/lib/types/components/webchatcontainerstateful/common/utils/attachmentActivityUtils.d.ts +9 -0
  88. package/lib/types/components/webchatcontainerstateful/common/utils/chatAdapterUtils.d.ts +9 -0
  89. package/lib/types/components/webchatcontainerstateful/interfaces/IBotAuthConfig.d.ts +4 -0
  90. package/lib/types/components/webchatcontainerstateful/interfaces/IWebChatContainerStatefulProps.d.ts +2 -0
  91. package/package.json +3 -3
@@ -2,7 +2,7 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function
2
2
  import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
3
3
  import { BroadcastService, BroadcastServiceInitialize, decodeComponentString } from "@microsoft/omnichannel-chat-components";
4
4
  import { Components } from "botframework-webchat";
5
- import { ConfirmationState, Constants, ConversationEndEntity, E2VVOptions, LiveWorkItemState, PrepareEndChatDescriptionConstants, StorageType } from "../../../common/Constants";
5
+ import { ConfirmationState, Constants, ConversationEndEntity, E2VVOptions, LiveWorkItemState, PrepareEndChatDescriptionConstants, StorageType, WidgetLoadCustomErrorString } from "../../../common/Constants";
6
6
  import { Stack } from "@fluentui/react";
7
7
  import React, { useEffect, useRef, useState } from "react";
8
8
  import { TelemetryManager, TelemetryTimers } from "../../../common/telemetry/TelemetryManager";
@@ -346,6 +346,23 @@ export const LiveChatWidgetStateful = props => {
346
346
  }
347
347
  }
348
348
  });
349
+ BroadcastService.getMessageByEventName(BroadcastEvent.NetworkReconnected).subscribe(async () => {
350
+ var _window2, _window2$location;
351
+ if (isThisSessionPopout((_window2 = window) === null || _window2 === void 0 ? void 0 : (_window2$location = _window2.location) === null || _window2$location === void 0 ? void 0 : _window2$location.href)) {
352
+ return;
353
+ }
354
+ const conversationDetails = await getConversationDetailsCall(chatSDK);
355
+ if ((conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.state) === LiveWorkItemState.WrapUp || (conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.state) === LiveWorkItemState.Closed) {
356
+ dispatch({
357
+ type: LiveChatWidgetActionType.SET_CHAT_DISCONNECT_EVENT_RECEIVED,
358
+ payload: true
359
+ });
360
+ TelemetryHelper.logActionEvent(LogLevel.INFO, {
361
+ Event: TelemetryEvent.ChatDisconnectThreadEventReceived,
362
+ Description: "Chat disconnected due to timeout, user went offline or blocked the device (including closing laptop)"
363
+ });
364
+ }
365
+ });
349
366
 
350
367
  /**
351
368
  * This will allow to sync multiple tabs to handle minimize and maximize state,
@@ -663,11 +680,24 @@ export const LiveChatWidgetStateful = props => {
663
680
 
664
681
  // Handle Chat disconnect cases
665
682
  useEffect(() => {
683
+ var _inMemoryState$appSta5;
666
684
  const inMemoryState = executeReducer(state, {
667
685
  type: LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
668
686
  payload: null
669
687
  });
670
688
  handleChatDisconnect(props, inMemoryState, setWebChatStyles);
689
+ const chatDisconnectState = inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$appSta5 = inMemoryState.appStates) === null || _inMemoryState$appSta5 === void 0 ? void 0 : _inMemoryState$appSta5.chatDisconnectEventReceived;
690
+ if (chatDisconnectState && adapter) {
691
+ try {
692
+ adapter.end();
693
+ adapter.close();
694
+ } catch (e) {
695
+ TelemetryHelper.logWebChatEvent(LogLevel.ERROR, {
696
+ Event: TelemetryEvent.EndingAdapterAfterDisconnectionError,
697
+ Description: WidgetLoadCustomErrorString.CloseAdapterAfterDisconnectionErrorString
698
+ });
699
+ }
700
+ }
671
701
  }, [state.appStates.chatDisconnectEventReceived]);
672
702
 
673
703
  // if props state gets updates we need to update the renderingMiddlewareProps in the state
@@ -0,0 +1,79 @@
1
+ import "rxjs/add/operator/share";
2
+ import "rxjs/add/observable/of";
3
+ import { Observable } from "rxjs/Observable";
4
+ import MockAdapter from "./mockadapter";
5
+ import { customerUser, postBotMessageActivity, postBotAttachmentActivity, postBotTypingActivity, postEchoActivity, postSystemMessageActivity } from "./utils/chatAdapterUtils";
6
+ import { createHeroCardAttachment, createJpgFileAttachment, createSigninCardAttachment, createThumbnailCardAttachment } from "./utils/attachmentActivityUtils";
7
+ import MockBotCommand from "./MockBotCommand";
8
+ import MockBotCardCommandType from "./MockBotCardCommandType";
9
+ export class DemoChatAdapter extends MockAdapter {
10
+ constructor() {
11
+ super();
12
+ setTimeout(() => {
13
+ postSystemMessageActivity(this.activityObserver, "You're currently using a demo.", 0);
14
+ postBotMessageActivity(this.activityObserver, "Type `/help` to learn more", undefined, 0); // send init message from bot
15
+ }, 1000);
16
+ }
17
+ postBotCommandsActivity() {
18
+ let delay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1000;
19
+ postBotAttachmentActivity(this.activityObserver, [{
20
+ contentType: "application/vnd.microsoft.card.thumbnail",
21
+ content: {
22
+ buttons: [{
23
+ title: "Send system message",
24
+ type: "imBack",
25
+ value: "send system message"
26
+ }, {
27
+ title: "Send typing",
28
+ type: "imBack",
29
+ value: "send typing"
30
+ }, {
31
+ title: "Send bot message",
32
+ type: "imBack",
33
+ value: "send bot message"
34
+ }],
35
+ title: "Commands"
36
+ }
37
+ }], delay);
38
+ }
39
+ postActivity(activity) {
40
+ if (activity) {
41
+ postEchoActivity(this.activityObserver, activity, customerUser);
42
+ if (activity.text) {
43
+ switch (true) {
44
+ case activity.text === MockBotCommand.Help:
45
+ this.postBotCommandsActivity();
46
+ break;
47
+ case activity.text === MockBotCommand.SendSystemMessage:
48
+ postSystemMessageActivity(this.activityObserver, "Contoso has joined the chat.");
49
+ break;
50
+ case activity.text === MockBotCommand.SendTyping:
51
+ postBotTypingActivity(this.activityObserver);
52
+ break;
53
+ case activity.text === MockBotCommand.SendAttachment:
54
+ postBotAttachmentActivity(this.activityObserver, [createJpgFileAttachment()]);
55
+ break;
56
+ case activity.text === MockBotCommand.SendBotMessage:
57
+ postBotMessageActivity(this.activityObserver, "Hi, how can I help you?");
58
+ break;
59
+ case activity.text === `${MockBotCommand.Card} ${MockBotCardCommandType.Signin}`:
60
+ postBotAttachmentActivity(this.activityObserver, [createSigninCardAttachment()]);
61
+ break;
62
+ case activity.text === `${MockBotCommand.Card} ${MockBotCardCommandType.Hero}`:
63
+ postBotAttachmentActivity(this.activityObserver, [createHeroCardAttachment()]);
64
+ break;
65
+ case activity.text === `${MockBotCommand.Card} ${MockBotCardCommandType.Thumbnail}`:
66
+ postBotAttachmentActivity(this.activityObserver, [createThumbnailCardAttachment()]);
67
+ break;
68
+ case activity.text.startsWith(`${MockBotCommand.Bot} `):
69
+ postBotMessageActivity(this.activityObserver, activity.text.substring(5));
70
+ break;
71
+ case activity.text.startsWith(`${MockBotCommand.System} `):
72
+ postSystemMessageActivity(this.activityObserver, activity.text.substring(8));
73
+ break;
74
+ }
75
+ }
76
+ }
77
+ return Observable.of(activity.id || "");
78
+ }
79
+ }
@@ -0,0 +1,10 @@
1
+ import { DemoChatAdapter } from "./DemoChatAdapter";
2
+ import { MockChatSDK } from "./mockchatsdk";
3
+ export class DemoChatSDK extends MockChatSDK {
4
+ constructor() {
5
+ super();
6
+ }
7
+ createChatAdapter() {
8
+ return new DemoChatAdapter();
9
+ }
10
+ }
@@ -0,0 +1,33 @@
1
+ import { Observable } from "rxjs/Observable";
2
+ import MockAdapter from "./mockadapter";
3
+ import { customerUser, postBotMessageActivity, postEchoActivity, postSystemMessageActivity } from "./utils/chatAdapterUtils";
4
+ export class DesignerChatAdapter extends MockAdapter {
5
+ constructor() {
6
+ super();
7
+ setTimeout(() => {
8
+ postBotMessageActivity(this.activityObserver, "Id venenatis a condimentum vitae?", undefined, 0);
9
+ this.postUserActivity("Diam donec adipiscing tristique risus nec feugiat in fermentum", 0);
10
+ postSystemMessageActivity(this.activityObserver, "We are finding the best agent for your inquiry, please hold ...", 100);
11
+ postSystemMessageActivity(this.activityObserver, "John has joined the chat", 100);
12
+ postBotMessageActivity(this.activityObserver, "Neque viverra justo nec ultrices dui sapien eget mi proin", undefined, 100);
13
+ }, 1000);
14
+ }
15
+ postUserActivity(text) {
16
+ let delay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1000;
17
+ setTimeout(() => {
18
+ postEchoActivity(this.activityObserver, {
19
+ text,
20
+ from: {
21
+ ...customerUser
22
+ },
23
+ type: "message"
24
+ }, customerUser, 0);
25
+ }, delay);
26
+ }
27
+ postActivity(activity) {
28
+ if (activity) {
29
+ postEchoActivity(this.activityObserver, activity, customerUser);
30
+ }
31
+ return Observable.of(activity.id || "");
32
+ }
33
+ }
@@ -0,0 +1,10 @@
1
+ import { DesignerChatAdapter } from "./DesignerChatAdapter";
2
+ import { MockChatSDK } from "./mockchatsdk";
3
+ export class DesignerChatSDK extends MockChatSDK {
4
+ constructor() {
5
+ super();
6
+ }
7
+ createChatAdapter() {
8
+ return new DesignerChatAdapter();
9
+ }
10
+ }
@@ -0,0 +1,7 @@
1
+ var MockBotCardCommandType;
2
+ (function (MockBotCardCommandType) {
3
+ MockBotCardCommandType["Hero"] = "hero";
4
+ MockBotCardCommandType["Signin"] = "signin";
5
+ MockBotCardCommandType["Thumbnail"] = "thumbnail";
6
+ })(MockBotCardCommandType || (MockBotCardCommandType = {}));
7
+ export default MockBotCardCommandType;
@@ -0,0 +1,12 @@
1
+ var MockBotCommand;
2
+ (function (MockBotCommand) {
3
+ MockBotCommand["Bot"] = "/bot";
4
+ MockBotCommand["Card"] = "/card";
5
+ MockBotCommand["Help"] = "/help";
6
+ MockBotCommand["SendAttachment"] = "send attachment";
7
+ MockBotCommand["SendBotMessage"] = "send bot message";
8
+ MockBotCommand["SendSystemMessage"] = "send system message";
9
+ MockBotCommand["SendTyping"] = "send typing";
10
+ MockBotCommand["System"] = "/system";
11
+ })(MockBotCommand || (MockBotCommand = {}));
12
+ export default MockBotCommand;
@@ -14,6 +14,9 @@ export class MockChatSDK {
14
14
  orgUrl: "https://contoso.crm.dynamics.com"
15
15
  });
16
16
  }
17
+ async initialize() {
18
+ return this.getLiveChatConfig();
19
+ }
17
20
  async startChat() {
18
21
  await this.sleep(1000);
19
22
  }
@@ -0,0 +1,61 @@
1
+ export const createJpgFileAttachment = () => {
2
+ return {
3
+ contentType: "image/jpeg",
4
+ name: "600x400.jpg",
5
+ contentUrl: "https://raw.githubusercontent.com/microsoft/omnichannel-chat-sdk/e7e75d4ede351e1cf2e52f13860d2284848c4af0/playwright/public/images/600x400.jpg"
6
+ };
7
+ };
8
+ export const createHeroCardAttachment = () => {
9
+ return {
10
+ contentType: "application/vnd.microsoft.card.hero",
11
+ content: {
12
+ buttons: [{
13
+ title: "Bellevue",
14
+ type: "imBack",
15
+ value: "Bellevue"
16
+ }, {
17
+ title: "Redmond",
18
+ type: "imBack",
19
+ value: "Redmond"
20
+ }, {
21
+ title: "Seattle",
22
+ type: "imBack",
23
+ value: "Seattle"
24
+ }],
25
+ title: "Choose your location"
26
+ }
27
+ };
28
+ };
29
+ export const createThumbnailCardAttachment = () => {
30
+ return {
31
+ contentType: "application/vnd.microsoft.card.thumbnail",
32
+ content: {
33
+ title: "Microsoft",
34
+ subtitle: "Our mission is to empower every person and every organization on the planet to achieve more.",
35
+ text: "Microsoft creates platforms and tools powered by AI to deliver innovative solutions that meet the evolving needs of our customers. The technology company is committed to making AI available broadly and doing so responsibly, with a mission to empower every person and every organization on the planet to achieve more.",
36
+ images: [{
37
+ alt: "Microsoft logo",
38
+ url: "https://img-prod-cms-rt-microsoft-com.akamaized.net/cms/api/am/imageFileData/RE1Mu3b?ver=5c31" // logo from https://microsoft.com
39
+ }],
40
+
41
+ buttons: [{
42
+ title: "Learn more",
43
+ type: "openUrl",
44
+ value: "https://www.microsoft.com/"
45
+ }]
46
+ }
47
+ };
48
+ };
49
+ export const createSigninCardAttachment = () => {
50
+ return {
51
+ contentType: "application/vnd.microsoft.card.signin",
52
+ content: {
53
+ text: "Please login",
54
+ buttons: [{
55
+ type: "signin",
56
+ title: "Signin",
57
+ value: "https://login.live.com/"
58
+ }]
59
+ }
60
+ };
61
+ };
@@ -0,0 +1,77 @@
1
+ import { uuidv4 } from "@microsoft/omnichannel-chat-sdk";
2
+ export const customerUser = {
3
+ id: "usedId",
4
+ name: "User",
5
+ role: "user"
6
+ };
7
+ export const botUser = {
8
+ id: "botId",
9
+ name: "Bot",
10
+ role: "bot"
11
+ };
12
+
13
+ // WebChat expects an "echo" activity to confirm the message has been sent successfully
14
+ export const postEchoActivity = function (activityObserver, activity, user) {
15
+ let delay = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1000;
16
+ const echoActivity = {
17
+ ...activity,
18
+ id: uuidv4(),
19
+ from: {
20
+ ...activity.from,
21
+ ...user
22
+ },
23
+ timestamp: new Date().toISOString()
24
+ };
25
+ setTimeout(() => {
26
+ activityObserver === null || activityObserver === void 0 ? void 0 : activityObserver.next(echoActivity); // mock message sent activity
27
+ }, delay);
28
+ };
29
+ export const postBotMessageActivity = function (activityObserver, text) {
30
+ let tags = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "";
31
+ let delay = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1000;
32
+ setTimeout(() => {
33
+ activityObserver === null || activityObserver === void 0 ? void 0 : activityObserver.next({
34
+ id: uuidv4(),
35
+ from: {
36
+ ...botUser
37
+ },
38
+ text,
39
+ type: "message",
40
+ channelData: {
41
+ tags
42
+ },
43
+ timestamp: new Date().toISOString()
44
+ });
45
+ }, delay);
46
+ };
47
+ export const postSystemMessageActivity = function (activityObserver, text) {
48
+ let delay = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1000;
49
+ postBotMessageActivity(activityObserver, text, "system", delay);
50
+ };
51
+ export const postBotTypingActivity = function (activityObserver) {
52
+ let delay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1000;
53
+ setTimeout(() => {
54
+ activityObserver === null || activityObserver === void 0 ? void 0 : activityObserver.next({
55
+ id: uuidv4(),
56
+ from: {
57
+ ...botUser
58
+ },
59
+ type: "typing"
60
+ });
61
+ }, delay);
62
+ };
63
+ export const postBotAttachmentActivity = function (activityObserver) {
64
+ let attachments = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
65
+ let delay = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1000;
66
+ setTimeout(() => {
67
+ activityObserver === null || activityObserver === void 0 ? void 0 : activityObserver.next({
68
+ id: uuidv4(),
69
+ from: {
70
+ ...botUser
71
+ },
72
+ attachments,
73
+ type: "message",
74
+ timestamp: new Date().toISOString()
75
+ });
76
+ }, delay);
77
+ };
@@ -371,6 +371,90 @@ class TranscriptHTMLBuilder {
371
371
  window.addEventListener("online", () => {
372
372
  document.body.innerHTML = \`${this.networkOnlineMessage} <button onclick="window.location.reload()"> Refresh </button>\`;
373
373
  });
374
+
375
+ document.addEventListener("copy", (event) => {
376
+ const clonedSelectedContent = window.getSelection().getRangeAt(0).cloneContents();
377
+ const copiedContent = document.createElement("div");
378
+ copiedContent.appendChild(clonedSelectedContent);
379
+
380
+ event.clipboardData.setData("text/plain", getAllText(copiedContent));
381
+ event.preventDefault();
382
+ });
383
+
384
+
385
+ getAllText = (element) => {
386
+ let plainText = "";
387
+ Array.from(element.childNodes).forEach((node) => {
388
+ // ignore aria-hidden elements and keyboard help text
389
+ const ariaHiddenAttr = node.attributes ? node.attributes.getNamedItem("aria-hidden") : null;
390
+ if ((ariaHiddenAttr && ariaHiddenAttr.value === "true") || node.classList && node.classList.contains("webchat__keyboard-help")) {
391
+ return;
392
+ }
393
+
394
+ // get all texts inside activity body, including message, translated message, attachment name, adaptive card content, status footer, etc.
395
+ if (node.classList && node.classList.contains("webchat__basic-transcript__activity-body")) {
396
+ plainText += this.processTranscriptActivityNode(node);
397
+ return;
398
+ }
399
+ if (node.nodeType === Node.TEXT_NODE) {
400
+ plainText += node.textContent + '\\n';
401
+ } else {
402
+ plainText += this.getAllText(node);
403
+ }
404
+ });
405
+ return plainText;
406
+ }
407
+
408
+ processTranscriptActivityNode = (node) => {
409
+ const divs = node.getElementsByTagName("div");
410
+ let plainText = "";
411
+
412
+ if (divs && divs.length > 1 && divs[1]) {
413
+ const messageRow = node.querySelector(".webchat__stacked-layout__message-row[aria-roledescription='message']");
414
+ const author = node.querySelector(".message-name");
415
+ const attachmentRow = node.querySelector(".webchat__stacked-layout__attachment-row[aria-roledescription='attachment']");
416
+
417
+ if (messageRow) {
418
+ let message = messageRow.getElementsByClassName("webchat__text-content__markdown");
419
+
420
+ if (message.length === 0) {
421
+ message = messageRow.getElementsByClassName("markdown");
422
+ }
423
+
424
+ if (message.length > 0) {
425
+ plainText += author.textContent + '\\n' + message[0].textContent + '\\n';
426
+ }
427
+ } else if (attachmentRow) {
428
+ const attachment = attachmentRow.getElementsByClassName("webchat__fileContent__fileName");
429
+ const adaptiveCard = this.getAdaptiveCardContent(attachmentRow.querySelector(".ac-container.ac-adaptiveCard"));
430
+
431
+ plainText += attachment && attachment.length > 0 ? author.textContent +'\\n' + attachment[0].textContent +'\\n': author.textContent +'\\n' + adaptiveCard +'\\n';
432
+ }
433
+
434
+ const statusElements = node.getElementsByClassName("webchat__stacked-layout__status");
435
+ if (statusElements.length > 0) {
436
+ const timestampelement = statusElements[0].querySelector(".message-timestamp");
437
+ plainText += timestampelement ? timestampelement.textContent+'\\n\\n' : '\\n';
438
+ }
439
+ }
440
+
441
+ return plainText;
442
+ }
443
+
444
+ getAdaptiveCardContent = (node) => {
445
+ if (!node) {
446
+ return undefined;
447
+ }
448
+
449
+ let plainText = "";
450
+ const rows = node.querySelectorAll(".ac-textBlock p");
451
+ rows.forEach((row) => {
452
+ plainText += row.textContent+ '\\n';
453
+ });
454
+
455
+ return plainText;
456
+ }
457
+
374
458
  <\/script>
375
459
  <div id="transcript"></div>
376
460
  <script>
@@ -14,7 +14,7 @@ export const createOnNewAdapterActivityHandler = (chatId, userId) => {
14
14
  const raiseMessageEvent = (activity, isHistoryMessage) => {
15
15
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
16
  const polyfillMessagePayloadForEvent = payload => {
17
- var _activity$conversatio, _TelemetryManager$Int;
17
+ var _activity$conversatio, _TelemetryManager$Int, _attachments;
18
18
  return {
19
19
  ...payload,
20
20
  channelData: activity === null || activity === void 0 ? void 0 : activity.channelData,
@@ -23,7 +23,9 @@ export const createOnNewAdapterActivityHandler = (chatId, userId) => {
23
23
  id: activity === null || activity === void 0 ? void 0 : activity.id,
24
24
  isChatComplete: false,
25
25
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
26
- text: activity === null || activity === void 0 ? void 0 : activity.text
26
+ text: activity === null || activity === void 0 ? void 0 : activity.text,
27
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
28
+ attachment: (activity === null || activity === void 0 ? void 0 : (_attachments = activity.attachments) === null || _attachments === void 0 ? void 0 : _attachments.length) >= 1 ? activity === null || activity === void 0 ? void 0 : activity.attachments : []
27
29
  };
28
30
  };
29
31
  if ((activity === null || activity === void 0 ? void 0 : activity.type) === Constants.message) {
@@ -254,6 +254,7 @@ export declare class WidgetLoadTelemetryMessage {
254
254
  export declare class WidgetLoadCustomErrorString {
255
255
  static readonly AuthenticationFailedErrorString = "Authentication was not successful";
256
256
  static readonly NetworkErrorString = "Network Error";
257
+ static readonly CloseAdapterAfterDisconnectionErrorString = "Error trying to end/close chat adapter after the widget is back on-line, for an already disconnected session";
257
258
  }
258
259
  export declare class PrepareEndChatDescriptionConstants {
259
260
  static readonly ConversationEndedByCustomerWithoutPostChat = "Conversation ended by customer. Post chat not configured or should not show.";
@@ -88,6 +88,7 @@ export declare enum TelemetryEvent {
88
88
  GetConversationDetailsCallStarted = "GetConversationDetailsCallStarted",
89
89
  GetConversationDetailsCallFailed = "GetConversationDetailsCallFailed",
90
90
  EndChatSDKCallFailed = "EndChatSDKCallFailed",
91
+ DisconnectEndChatSDKCallFailed = "DisconnectEndChatSDKCallFailed",
91
92
  GetChatReconnectContextSDKCallStarted = "GetChatReconnectContextSDKCallStarted",
92
93
  GetChatReconnectContextSDKCallFailed = "GetChatReconnectContextSDKCallFailed",
93
94
  ParseAdaptiveCardFailed = "ParseAdaptiveCardFailed",
@@ -200,7 +201,9 @@ export declare enum TelemetryEvent {
200
201
  PostChatContextCallFailed = "PostChatContextCallFailed",
201
202
  PostChatSurveyLoadingPaneLoaded = "PostChatSurveyLoadingPaneLoaded",
202
203
  PostChatSurveyLoaded = "PostChatSurveyLoaded",
203
- ChatDisconnectThreadEventReceived = "ChatDisconnectThreadEventReceived"
204
+ ChatDisconnectThreadEventReceived = "ChatDisconnectThreadEventReceived",
205
+ HiddenAdaptiveCardMessageReceived = "HiddenAdaptiveCardMessageReceived",
206
+ EndingAdapterAfterDisconnectionError = "EndingAdapterAfterDisconnectionError"
204
207
  }
205
208
  export interface TelemetryInput {
206
209
  scenarioType: ScenarioType;
@@ -1,8 +1,11 @@
1
1
  import { IActivitySubscriber } from "./IActivitySubscriber";
2
+ import { IBotAuthActivitySubscriberOptionalParams } from "../../interfaces/IBotAuthActivitySubscriberOptionalParams";
2
3
  export declare class BotAuthActivitySubscriber implements IActivitySubscriber {
3
4
  observer: any;
4
5
  private signInCardSeen;
5
- constructor();
6
+ private fetchBotAuthConfigRetries;
7
+ private fetchBotAuthConfigRetryInterval;
8
+ constructor(optionalParams?: IBotAuthActivitySubscriberOptionalParams);
6
9
  applicable(activity: any): boolean;
7
10
  apply(activity: any): Promise<any>;
8
11
  next(activity: any): Promise<any>;
@@ -0,0 +1,7 @@
1
+ import { IActivitySubscriber } from "./IActivitySubscriber";
2
+ export declare class HiddenAdaptiveCardActivitySubscriber implements IActivitySubscriber {
3
+ observer: any;
4
+ apply(activity: any): Promise<void>;
5
+ applicable(activity: any): boolean;
6
+ next(activity: any): Promise<any>;
7
+ }
@@ -1 +1,2 @@
1
- export declare const createAdapter: (chatSDK: any) => Promise<any>;
1
+ import { ILiveChatWidgetProps } from "../interfaces/ILiveChatWidgetProps";
2
+ export declare const createAdapter: (chatSDK: any, props?: ILiveChatWidgetProps | undefined) => Promise<any>;
@@ -0,0 +1 @@
1
+ export declare const getMockChatSDKIfApplicable: (chatSDK: any, type?: string | undefined) => any;
@@ -0,0 +1,2 @@
1
+ import MarkdownIt from "markdown-it";
2
+ export declare const addSlackMarkdownIt: (markdown: MarkdownIt) => MarkdownIt;
@@ -0,0 +1,3 @@
1
+ import { ILiveChatWidgetProps } from "../interfaces/ILiveChatWidgetProps";
2
+ declare const overridePropsOnMockIfApplicable: (props: ILiveChatWidgetProps) => void;
3
+ export default overridePropsOnMockIfApplicable;
@@ -1,3 +1,3 @@
1
1
  import { Dispatch } from "react";
2
2
  import { ILiveChatWidgetAction } from "../../../contexts/common/ILiveChatWidgetAction";
3
- export declare const updateSessionDataForTelemetry: (chatSDK: any, dispatch: Dispatch<ILiveChatWidgetAction>) => Promise<void>;
3
+ export declare const updateTelemetryData: (chatSDK: any, dispatch: Dispatch<ILiveChatWidgetAction>) => Promise<void>;
@@ -0,0 +1,4 @@
1
+ export interface IBotAuthActivitySubscriberOptionalParams {
2
+ fetchBotAuthConfigRetries?: number;
3
+ fetchBotAuthConfigRetryInterval?: number;
4
+ }
@@ -25,6 +25,7 @@ import { IPostChatSurveyPaneStatefulProps } from "../../postchatsurveypanestatef
25
25
  import { IScrollBarProps } from "./IScrollBarProps";
26
26
  import { IDraggableChatWidgetProps } from "./IDraggableChatWidgetProps";
27
27
  import { INotificationPaneProps } from "@microsoft/omnichannel-chat-components/lib/types/components/notificationpane/interfaces/INotificationPaneProps";
28
+ import { IMockProps } from "./IMockProps";
28
29
  export interface ILiveChatWidgetProps {
29
30
  audioNotificationProps?: IAudioNotificationProps;
30
31
  callingContainerProps?: ICallingContainerProps;
@@ -61,4 +62,5 @@ export interface ILiveChatWidgetProps {
61
62
  allowSdkChatSupport?: boolean;
62
63
  initialCustomContext?: any;
63
64
  draggableChatWidgetProps?: IDraggableChatWidgetProps;
65
+ mock?: IMockProps;
64
66
  }
@@ -0,0 +1,8 @@
1
+ declare enum LiveChatWidgetMockType {
2
+ Test = "Test",
3
+ Demo = "Demo"
4
+ }
5
+ export interface IMockProps {
6
+ type: LiveChatWidgetMockType;
7
+ }
8
+ export {};
@@ -0,0 +1,10 @@
1
+ import "rxjs/add/operator/share";
2
+ import "rxjs/add/observable/of";
3
+ import { Message } from "botframework-directlinejs";
4
+ import { Observable } from "rxjs/Observable";
5
+ import MockAdapter from "./mockadapter";
6
+ export declare class DemoChatAdapter extends MockAdapter {
7
+ constructor();
8
+ private postBotCommandsActivity;
9
+ postActivity(activity: Message): Observable<string>;
10
+ }
@@ -0,0 +1,6 @@
1
+ import { DemoChatAdapter } from "./DemoChatAdapter";
2
+ import { MockChatSDK } from "./mockchatsdk";
3
+ export declare class DemoChatSDK extends MockChatSDK {
4
+ constructor();
5
+ createChatAdapter(): DemoChatAdapter;
6
+ }
@@ -0,0 +1,8 @@
1
+ import { Message } from "botframework-directlinejs";
2
+ import { Observable } from "rxjs/Observable";
3
+ import MockAdapter from "./mockadapter";
4
+ export declare class DesignerChatAdapter extends MockAdapter {
5
+ constructor();
6
+ private postUserActivity;
7
+ postActivity(activity: Message): Observable<string>;
8
+ }
@@ -0,0 +1,6 @@
1
+ import { DesignerChatAdapter } from "./DesignerChatAdapter";
2
+ import { MockChatSDK } from "./mockchatsdk";
3
+ export declare class DesignerChatSDK extends MockChatSDK {
4
+ constructor();
5
+ createChatAdapter(): DesignerChatAdapter;
6
+ }
@@ -0,0 +1,6 @@
1
+ declare enum MockBotCardCommandType {
2
+ Hero = "hero",
3
+ Signin = "signin",
4
+ Thumbnail = "thumbnail"
5
+ }
6
+ export default MockBotCardCommandType;
@@ -0,0 +1,11 @@
1
+ declare enum MockBotCommand {
2
+ Bot = "/bot",
3
+ Card = "/card",
4
+ Help = "/help",
5
+ SendAttachment = "send attachment",
6
+ SendBotMessage = "send bot message",
7
+ SendSystemMessage = "send system message",
8
+ SendTyping = "send typing",
9
+ System = "/system"
10
+ }
11
+ export default MockBotCommand;