@microsoft/omnichannel-chat-widget 1.7.3-main.fee24eb → 1.7.4-main.9d63968

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 (53) hide show
  1. package/lib/cjs/common/Constants.js +1 -0
  2. package/lib/cjs/common/telemetry/TelemetryConstants.js +2 -0
  3. package/lib/cjs/components/footerstateful/FooterStateful.js +14 -3
  4. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +15 -6
  5. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/HiddenAdaptiveCardActivitySubscriber.js +77 -0
  6. package/lib/cjs/components/livechatwidget/common/chatDisconnectHelper.js +2 -2
  7. package/lib/cjs/components/livechatwidget/common/createAdapter.js +15 -2
  8. package/lib/cjs/components/livechatwidget/common/createInternetConnectionChangeHandler.js +6 -2
  9. package/lib/cjs/components/livechatwidget/common/createMarkdown.js +2 -2
  10. package/lib/cjs/components/livechatwidget/common/helpers/markdownHelper.js +23 -0
  11. package/lib/cjs/components/livechatwidget/common/persistentChatHelper.js +2 -1
  12. package/lib/cjs/components/livechatwidget/common/startChat.js +3 -3
  13. package/lib/cjs/components/livechatwidget/interfaces/IBotAuthActivitySubscriberOptionalParams.js +1 -0
  14. package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +30 -0
  15. package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +11 -6
  16. package/lib/cjs/components/webchatcontainerstateful/common/DesignerChatAdapter.js +4 -4
  17. package/lib/cjs/components/webchatcontainerstateful/common/DesignerChatSDK.js +31 -0
  18. package/lib/cjs/components/webchatcontainerstateful/interfaces/IBotAuthConfig.js +1 -0
  19. package/lib/cjs/index.js +7 -0
  20. package/lib/cjs/plugins/createChatTranscript.js +84 -0
  21. package/lib/esm/common/Constants.js +1 -0
  22. package/lib/esm/common/telemetry/TelemetryConstants.js +2 -0
  23. package/lib/esm/components/footerstateful/FooterStateful.js +12 -3
  24. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +15 -6
  25. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/HiddenAdaptiveCardActivitySubscriber.js +70 -0
  26. package/lib/esm/components/livechatwidget/common/chatDisconnectHelper.js +3 -2
  27. package/lib/esm/components/livechatwidget/common/createAdapter.js +14 -2
  28. package/lib/esm/components/livechatwidget/common/createInternetConnectionChangeHandler.js +6 -2
  29. package/lib/esm/components/livechatwidget/common/createMarkdown.js +2 -2
  30. package/lib/esm/components/livechatwidget/common/helpers/markdownHelper.js +15 -0
  31. package/lib/esm/components/livechatwidget/common/persistentChatHelper.js +2 -1
  32. package/lib/esm/components/livechatwidget/common/startChat.js +3 -3
  33. package/lib/esm/components/livechatwidget/interfaces/IBotAuthActivitySubscriberOptionalParams.js +1 -0
  34. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +31 -1
  35. package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +11 -6
  36. package/lib/esm/components/webchatcontainerstateful/common/DesignerChatAdapter.js +4 -4
  37. package/lib/esm/components/webchatcontainerstateful/common/DesignerChatSDK.js +31 -0
  38. package/lib/esm/components/webchatcontainerstateful/interfaces/IBotAuthConfig.js +1 -0
  39. package/lib/esm/index.js +1 -0
  40. package/lib/esm/plugins/createChatTranscript.js +84 -0
  41. package/lib/types/common/Constants.d.ts +1 -0
  42. package/lib/types/common/telemetry/TelemetryConstants.d.ts +3 -1
  43. package/lib/types/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.d.ts +4 -1
  44. package/lib/types/components/livechatwidget/common/ActivitySubscriber/HiddenAdaptiveCardActivitySubscriber.d.ts +7 -0
  45. package/lib/types/components/livechatwidget/common/createAdapter.d.ts +2 -1
  46. package/lib/types/components/livechatwidget/common/helpers/markdownHelper.d.ts +2 -0
  47. package/lib/types/components/livechatwidget/interfaces/IBotAuthActivitySubscriberOptionalParams.d.ts +4 -0
  48. package/lib/types/components/webchatcontainerstateful/common/DesignerChatSDK.d.ts +25 -0
  49. package/lib/types/components/webchatcontainerstateful/interfaces/IAdaptiveCardStyles.d.ts +1 -0
  50. package/lib/types/components/webchatcontainerstateful/interfaces/IBotAuthConfig.d.ts +4 -0
  51. package/lib/types/components/webchatcontainerstateful/interfaces/IWebChatContainerStatefulProps.d.ts +2 -0
  52. package/lib/types/index.d.ts +1 -0
  53. package/package.json +2 -2
@@ -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>
@@ -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.";
@@ -201,7 +201,9 @@ export declare enum TelemetryEvent {
201
201
  PostChatContextCallFailed = "PostChatContextCallFailed",
202
202
  PostChatSurveyLoadingPaneLoaded = "PostChatSurveyLoadingPaneLoaded",
203
203
  PostChatSurveyLoaded = "PostChatSurveyLoaded",
204
- ChatDisconnectThreadEventReceived = "ChatDisconnectThreadEventReceived"
204
+ ChatDisconnectThreadEventReceived = "ChatDisconnectThreadEventReceived",
205
+ HiddenAdaptiveCardMessageReceived = "HiddenAdaptiveCardMessageReceived",
206
+ EndingAdapterAfterDisconnectionError = "EndingAdapterAfterDisconnectionError"
205
207
  }
206
208
  export interface TelemetryInput {
207
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,2 @@
1
+ import MarkdownIt from "markdown-it";
2
+ export declare const addSlackMarkdownIt: (markdown: MarkdownIt) => MarkdownIt;
@@ -0,0 +1,4 @@
1
+ export interface IBotAuthActivitySubscriberOptionalParams {
2
+ fetchBotAuthConfigRetries?: number;
3
+ fetchBotAuthConfigRetryInterval?: number;
4
+ }
@@ -3,4 +3,29 @@ import { MockChatSDK } from "./mockchatsdk";
3
3
  export declare class DesignerChatSDK extends MockChatSDK {
4
4
  constructor();
5
5
  createChatAdapter(): DesignerChatAdapter;
6
+ localeId: string;
7
+ /**
8
+ * If the widget is running in designer mode, we mock the initialize response. We don't want
9
+ * any interactions with a real server in when designing LCW widget visually in Modern Admin.
10
+ *
11
+ * - All GUIDs were changed to 00000000-0000-0000-0000-000000000000.
12
+ * - msdyn_callingoptions was changed to disable calling functionality
13
+ */
14
+ getLiveChatConfig(): {
15
+ LiveWSAndLiveChatEngJoin: {
16
+ msdyn_widgetthemecolor: string;
17
+ msdyn_callingoptions: string;
18
+ msdyn_widgettitle: string;
19
+ msdyn_conversationmode: string;
20
+ msdyn_avatarurl: string;
21
+ msdyn_name: string;
22
+ msdyn_postconversationsurveyenable: string;
23
+ OutOfOperatingHours: string;
24
+ ShowWidget: string;
25
+ };
26
+ ChatWidgetLanguage: {
27
+ msdyn_localeid: string;
28
+ msdyn_languagename: string;
29
+ };
30
+ };
6
31
  }
@@ -4,4 +4,5 @@ export interface IAdaptiveCardStyles {
4
4
  anchorColor?: string;
5
5
  buttonWhiteSpace?: string;
6
6
  textWhiteSpace?: string;
7
+ choiceInputPadding?: string;
7
8
  }
@@ -0,0 +1,4 @@
1
+ export interface IBotAuthConfig {
2
+ fetchBotAuthConfigRetries?: number;
3
+ fetchBotAuthConfigRetryInterval?: number;
4
+ }
@@ -5,6 +5,7 @@ import { IStyle } from "@fluentui/react";
5
5
  import { IWebChatProps } from "./IWebChatProps";
6
6
  import { StyleOptions } from "botframework-webchat-api";
7
7
  import { IAdaptiveCardStyles } from "./IAdaptiveCardStyles";
8
+ import { IBotAuthConfig } from "./IBotAuthConfig";
8
9
  export interface IWebChatContainerStatefulProps {
9
10
  containerStyles?: IStyle;
10
11
  disableNewLineMarkdownSupport?: boolean;
@@ -16,6 +17,7 @@ export interface IWebChatContainerStatefulProps {
16
17
  renderingMiddlewareProps?: IRenderingMiddlewareProps;
17
18
  localizedTexts?: ILiveChatWidgetLocalizedTexts;
18
19
  botMagicCode?: IBotMagicCodeConfig;
20
+ botAuthConfig?: IBotAuthConfig;
19
21
  hyperlinkTextOverride?: boolean;
20
22
  adaptiveCardStyles?: IAdaptiveCardStyles;
21
23
  }
@@ -4,5 +4,6 @@ import useChatSDKStore from "./hooks/useChatSDKStore";
4
4
  import { getWidgetCacheId, getWidgetEndChatEventName } from "./common/utils";
5
5
  import { ConversationState } from "./contexts/common/ConversationState";
6
6
  export { default as LiveChatWidget } from "./components/livechatwidget/LiveChatWidget";
7
+ export { getMockChatSDKIfApplicable } from "./components/livechatwidget/common/getMockChatSDKIfApplicable";
7
8
  export { encodeComponentString, decodeComponentString, BroadcastService, useChatSDKStore, useChatContextStore };
8
9
  export { getWidgetCacheId, getWidgetEndChatEventName, ConversationState };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microsoft/omnichannel-chat-widget",
3
- "version": "1.7.3-main.fee24eb",
3
+ "version": "1.7.4-main.9d63968",
4
4
  "description": "Microsoft Omnichannel Chat Widget",
5
5
  "main": "lib/cjs/index.js",
6
6
  "types": "lib/types/index.d.ts",
@@ -75,7 +75,7 @@
75
75
  },
76
76
  "dependencies": {
77
77
  "@microsoft/omnichannel-chat-components": "1.1.5",
78
- "@microsoft/omnichannel-chat-sdk": "^1.9.6",
78
+ "@microsoft/omnichannel-chat-sdk": "^1.10.1",
79
79
  "abort-controller-es5": "^2.0.1",
80
80
  "dompurify": "^2.5.4",
81
81
  "markdown-it": "^12.3.2",