@microsoft/omnichannel-chat-widget 1.6.5 → 1.6.6-main.a655e3b
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/lib/cjs/common/utils.js +16 -2
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +10 -3
- package/lib/esm/common/utils.js +13 -0
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +11 -4
- package/lib/types/common/utils.d.ts +1 -0
- package/lib/types/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.d.ts +1 -1
- package/package.json +4 -4
package/lib/cjs/common/utils.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.setTabIndices = exports.setFocusOnSendBox = exports.setFocusOnElement = exports.preventFocusToMoveOutOfElement = exports.parseLowerCaseString = exports.parseAdaptiveCardPayload = exports.newGuid = exports.isUndefinedOrEmpty = exports.isNullOrUndefined = exports.isNullOrEmptyString = exports.getWidgetEndChatEventName = exports.getWidgetCacheIdfromProps = exports.getWidgetCacheId = exports.getTimestampHourMinute = exports.getStateFromCache = exports.getLocaleDirection = exports.getIconText = exports.getDomain = exports.getConversationDetailsCall = exports.getBroadcastChannelName = exports.formatTemplateString = exports.findParentFocusableElementsWithoutChildContainer = exports.findAllFocusableElement = exports.extractPreChatSurveyResponseValues = exports.escapeHtml = exports.debounceLeading = exports.createTimer = exports.createFileAndDownload = exports.checkContactIdError = exports.changeLanguageCodeFormatForWebChat = exports.addDelayInMs = void 0;
|
|
6
|
+
exports.setTabIndices = exports.setOcUserAgent = exports.setFocusOnSendBox = exports.setFocusOnElement = exports.preventFocusToMoveOutOfElement = exports.parseLowerCaseString = exports.parseAdaptiveCardPayload = exports.newGuid = exports.isUndefinedOrEmpty = exports.isNullOrUndefined = exports.isNullOrEmptyString = exports.getWidgetEndChatEventName = exports.getWidgetCacheIdfromProps = exports.getWidgetCacheId = exports.getTimestampHourMinute = exports.getStateFromCache = exports.getLocaleDirection = exports.getIconText = exports.getDomain = exports.getConversationDetailsCall = exports.getBroadcastChannelName = exports.formatTemplateString = exports.findParentFocusableElementsWithoutChildContainer = exports.findAllFocusableElement = exports.extractPreChatSurveyResponseValues = exports.escapeHtml = exports.debounceLeading = exports.createTimer = exports.createFileAndDownload = exports.checkContactIdError = exports.changeLanguageCodeFormatForWebChat = exports.addDelayInMs = void 0;
|
|
7
7
|
var _Constants = require("./Constants");
|
|
8
8
|
var _TelemetryConstants = require("./telemetry/TelemetryConstants");
|
|
9
9
|
var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
|
|
@@ -458,4 +458,18 @@ exports.formatTemplateString = formatTemplateString;
|
|
|
458
458
|
const parseLowerCaseString = property => {
|
|
459
459
|
return String(property).toLowerCase();
|
|
460
460
|
};
|
|
461
|
-
exports.parseLowerCaseString = parseLowerCaseString;
|
|
461
|
+
exports.parseLowerCaseString = parseLowerCaseString;
|
|
462
|
+
const setOcUserAgent = chatSDK => {
|
|
463
|
+
var _chatSDK$OCClient, _chatSDK$OCClient2;
|
|
464
|
+
// eslint-disable-line @typescript-eslint/no-explicit-any
|
|
465
|
+
if ((_chatSDK$OCClient = chatSDK.OCClient) !== null && _chatSDK$OCClient !== void 0 && _chatSDK$OCClient.ocUserAgent && !((_chatSDK$OCClient2 = chatSDK.OCClient) !== null && _chatSDK$OCClient2 !== void 0 && _chatSDK$OCClient2.ocUserAgent.join(" ").includes("omnichannel-chat-widget/"))) {
|
|
466
|
+
try {
|
|
467
|
+
const version = require("../../../package.json").version; // eslint-disable-line @typescript-eslint/no-var-requires
|
|
468
|
+
const userAgent = `omnichannel-chat-widget/${version}`;
|
|
469
|
+
chatSDK.OCClient.ocUserAgent = [userAgent, ...chatSDK.OCClient.ocUserAgent];
|
|
470
|
+
} catch (error) {
|
|
471
|
+
console.warn(error);
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
};
|
|
475
|
+
exports.setOcUserAgent = setOcUserAgent;
|
|
@@ -63,7 +63,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
63
63
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
64
64
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
65
65
|
const LiveChatWidgetStateful = props => {
|
|
66
|
-
var _props$webChatContain, _props$styleProps, _props$controlProps, _props$controlProps3, _state$appStates7, _props$webChatContain5, _state$appStates14, _props$webChatContain7, _props$webChatContain8, _props$controlProps12, _props$draggableChatW, _props$draggableChatW2, _props$draggableChatW3, _props$draggableChatW4, _props$draggableChatW5, _props$webChatContain9, _props$webChatContain10, _props$webChatContain11, _props$webChatContain12, _livechatProps$
|
|
66
|
+
var _props$webChatContain, _props$styleProps, _props$controlProps, _props$controlProps3, _state$appStates7, _props$webChatContain5, _state$appStates14, _props$webChatContain7, _props$webChatContain8, _props$controlProps12, _props$draggableChatW, _props$draggableChatW2, _props$draggableChatW3, _props$draggableChatW4, _props$draggableChatW5, _livechatProps$webCha, _props$webChatContain9, _props$webChatContain10, _props$webChatContain11, _props$webChatContain12, _livechatProps$styleP, _livechatProps$contro, _livechatProps$contro2, _livechatProps$compon, _livechatProps$contro3, _livechatProps$compon2, _livechatProps$contro4, _livechatProps$compon3, _livechatProps$contro5, _livechatProps$compon4, _livechatProps$contro6, _livechatProps$compon5, _livechatProps$contro7, _livechatProps$compon6, _livechatProps$contro8, _livechatProps$compon7, _livechatProps$contro9, _livechatProps$compon8, _livechatProps$contro10, _livechatProps$contro11, _livechatProps$compon9, _livechatProps$contro12, _livechatProps$compon10, _livechatProps$contro13, _livechatProps$compon11, _livechatProps$compon12, _livechatProps$compon13;
|
|
67
67
|
const [state, dispatch] = (0, _useChatContextStore.default)();
|
|
68
68
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
69
69
|
const [adapter, setAdapter] = (0, _useChatAdapterStore.default)();
|
|
@@ -730,7 +730,13 @@ const LiveChatWidgetStateful = props => {
|
|
|
730
730
|
draggable: ((_props$draggableChatW5 = props.draggableChatWidgetProps) === null || _props$draggableChatW5 === void 0 ? void 0 : _props$draggableChatW5.disabled) !== true // Draggable by default, unless explicitly disabled
|
|
731
731
|
};
|
|
732
732
|
|
|
733
|
-
|
|
733
|
+
// Add 'omnichannel-chat-widget' OC User Agent if not already set
|
|
734
|
+
(0, _utils.setOcUserAgent)(chatSDK);
|
|
735
|
+
const directLine = ((_livechatProps$webCha = livechatProps.webChatContainerProps) === null || _livechatProps$webCha === void 0 ? void 0 : _livechatProps$webCha.directLine) ?? adapter ?? _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.directLine;
|
|
736
|
+
const userID = directLine.getState ? directLine === null || directLine === void 0 ? void 0 : directLine.getState("acs.userId") : "teamsvisitor";
|
|
737
|
+
|
|
738
|
+
// WebChat's Composer can only be rendered if a directLine object is defined
|
|
739
|
+
return directLine && /*#__PURE__*/_react2.default.createElement(_react2.default.Fragment, null, /*#__PURE__*/_react2.default.createElement("style", null, `
|
|
734
740
|
::-webkit-scrollbar {
|
|
735
741
|
width: ${scrollbarProps.width};
|
|
736
742
|
}
|
|
@@ -757,12 +763,13 @@ const LiveChatWidgetStateful = props => {
|
|
|
757
763
|
}
|
|
758
764
|
}
|
|
759
765
|
`), /*#__PURE__*/_react2.default.createElement(_DraggableChatWidget.default, chatWidgetDraggableConfig, /*#__PURE__*/_react2.default.createElement(Composer, _extends({}, webChatProps, {
|
|
766
|
+
userID: userID,
|
|
760
767
|
styleOptions: {
|
|
761
768
|
...webChatStyles,
|
|
762
769
|
bubbleBackground: ((_props$webChatContain9 = props.webChatContainerProps) === null || _props$webChatContain9 === void 0 ? void 0 : (_props$webChatContain10 = _props$webChatContain9.adaptiveCardStyles) === null || _props$webChatContain10 === void 0 ? void 0 : _props$webChatContain10.background) ?? _defaultAdaptiveCardStyles.defaultAdaptiveCardStyles.background,
|
|
763
770
|
bubbleTextColor: ((_props$webChatContain11 = props.webChatContainerProps) === null || _props$webChatContain11 === void 0 ? void 0 : (_props$webChatContain12 = _props$webChatContain11.adaptiveCardStyles) === null || _props$webChatContain12 === void 0 ? void 0 : _props$webChatContain12.color) ?? _defaultAdaptiveCardStyles.defaultAdaptiveCardStyles.color
|
|
764
771
|
},
|
|
765
|
-
directLine:
|
|
772
|
+
directLine: directLine
|
|
766
773
|
}), /*#__PURE__*/_react2.default.createElement(_react.Stack, {
|
|
767
774
|
id: widgetElementId,
|
|
768
775
|
styles: generalStyles,
|
package/lib/esm/common/utils.js
CHANGED
|
@@ -421,4 +421,17 @@ export const formatTemplateString = (templateMessage, values) => {
|
|
|
421
421
|
};
|
|
422
422
|
export const parseLowerCaseString = property => {
|
|
423
423
|
return String(property).toLowerCase();
|
|
424
|
+
};
|
|
425
|
+
export const setOcUserAgent = chatSDK => {
|
|
426
|
+
var _chatSDK$OCClient, _chatSDK$OCClient2;
|
|
427
|
+
// eslint-disable-line @typescript-eslint/no-explicit-any
|
|
428
|
+
if ((_chatSDK$OCClient = chatSDK.OCClient) !== null && _chatSDK$OCClient !== void 0 && _chatSDK$OCClient.ocUserAgent && !((_chatSDK$OCClient2 = chatSDK.OCClient) !== null && _chatSDK$OCClient2 !== void 0 && _chatSDK$OCClient2.ocUserAgent.join(" ").includes("omnichannel-chat-widget/"))) {
|
|
429
|
+
try {
|
|
430
|
+
const version = require("../../../package.json").version; // eslint-disable-line @typescript-eslint/no-var-requires
|
|
431
|
+
const userAgent = `omnichannel-chat-widget/${version}`;
|
|
432
|
+
chatSDK.OCClient.ocUserAgent = [userAgent, ...chatSDK.OCClient.ocUserAgent];
|
|
433
|
+
} catch (error) {
|
|
434
|
+
console.warn(error);
|
|
435
|
+
}
|
|
436
|
+
}
|
|
424
437
|
};
|
|
@@ -6,7 +6,7 @@ import { ConfirmationState, Constants, ConversationEndEntity, E2VVOptions, LiveW
|
|
|
6
6
|
import { Stack } from "@fluentui/react";
|
|
7
7
|
import React, { useEffect, useRef, useState } from "react";
|
|
8
8
|
import { checkIfConversationStillValid, initStartChat, prepareStartChat, setPreChatAndInitiateChat } from "../common/startChat";
|
|
9
|
-
import { createTimer, getBroadcastChannelName, getConversationDetailsCall, getLocaleDirection, getStateFromCache, getWidgetCacheIdfromProps, getWidgetEndChatEventName, isNullOrEmptyString, isNullOrUndefined, isUndefinedOrEmpty } from "../../../common/utils";
|
|
9
|
+
import { createTimer, getBroadcastChannelName, getConversationDetailsCall, getLocaleDirection, getStateFromCache, getWidgetCacheIdfromProps, getWidgetEndChatEventName, isNullOrEmptyString, isNullOrUndefined, isUndefinedOrEmpty, setOcUserAgent } from "../../../common/utils";
|
|
10
10
|
import { defaultClientDataStoreProvider, isCookieAllowed } from "../../../common/storage/default/defaultClientDataStoreProvider";
|
|
11
11
|
import { chatSDKStateCleanUp, endChat, endChatStateCleanUp, prepareEndChat } from "../common/endChat";
|
|
12
12
|
import { handleChatReconnect, isPersistentEnabled, isReconnectEnabled } from "../common/reconnectChatHelper";
|
|
@@ -55,7 +55,7 @@ import StartChatErrorPaneStateful from "../../startchaterrorpanestateful/StartCh
|
|
|
55
55
|
import { StartChatFailureType } from "../../../contexts/common/StartChatFailureType";
|
|
56
56
|
import { executeReducer } from "../../../contexts/createReducer";
|
|
57
57
|
export const LiveChatWidgetStateful = props => {
|
|
58
|
-
var _props$webChatContain, _props$styleProps, _props$controlProps, _props$controlProps3, _state$appStates7, _props$webChatContain5, _state$appStates14, _props$webChatContain7, _props$webChatContain8, _props$controlProps12, _props$draggableChatW, _props$draggableChatW2, _props$draggableChatW3, _props$draggableChatW4, _props$draggableChatW5, _props$webChatContain9, _props$webChatContain10, _props$webChatContain11, _props$webChatContain12, _livechatProps$
|
|
58
|
+
var _props$webChatContain, _props$styleProps, _props$controlProps, _props$controlProps3, _state$appStates7, _props$webChatContain5, _state$appStates14, _props$webChatContain7, _props$webChatContain8, _props$controlProps12, _props$draggableChatW, _props$draggableChatW2, _props$draggableChatW3, _props$draggableChatW4, _props$draggableChatW5, _livechatProps$webCha, _props$webChatContain9, _props$webChatContain10, _props$webChatContain11, _props$webChatContain12, _livechatProps$styleP, _livechatProps$contro, _livechatProps$contro2, _livechatProps$compon, _livechatProps$contro3, _livechatProps$compon2, _livechatProps$contro4, _livechatProps$compon3, _livechatProps$contro5, _livechatProps$compon4, _livechatProps$contro6, _livechatProps$compon5, _livechatProps$contro7, _livechatProps$compon6, _livechatProps$contro8, _livechatProps$compon7, _livechatProps$contro9, _livechatProps$compon8, _livechatProps$contro10, _livechatProps$contro11, _livechatProps$compon9, _livechatProps$contro12, _livechatProps$compon10, _livechatProps$contro13, _livechatProps$compon11, _livechatProps$compon12, _livechatProps$compon13;
|
|
59
59
|
const [state, dispatch] = useChatContextStore();
|
|
60
60
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
61
61
|
const [adapter, setAdapter] = useChatAdapterStore();
|
|
@@ -722,7 +722,13 @@ export const LiveChatWidgetStateful = props => {
|
|
|
722
722
|
draggable: ((_props$draggableChatW5 = props.draggableChatWidgetProps) === null || _props$draggableChatW5 === void 0 ? void 0 : _props$draggableChatW5.disabled) !== true // Draggable by default, unless explicitly disabled
|
|
723
723
|
};
|
|
724
724
|
|
|
725
|
-
|
|
725
|
+
// Add 'omnichannel-chat-widget' OC User Agent if not already set
|
|
726
|
+
setOcUserAgent(chatSDK);
|
|
727
|
+
const directLine = ((_livechatProps$webCha = livechatProps.webChatContainerProps) === null || _livechatProps$webCha === void 0 ? void 0 : _livechatProps$webCha.directLine) ?? adapter ?? defaultWebChatContainerStatefulProps.directLine;
|
|
728
|
+
const userID = directLine.getState ? directLine === null || directLine === void 0 ? void 0 : directLine.getState("acs.userId") : "teamsvisitor";
|
|
729
|
+
|
|
730
|
+
// WebChat's Composer can only be rendered if a directLine object is defined
|
|
731
|
+
return directLine && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("style", null, `
|
|
726
732
|
::-webkit-scrollbar {
|
|
727
733
|
width: ${scrollbarProps.width};
|
|
728
734
|
}
|
|
@@ -749,12 +755,13 @@ export const LiveChatWidgetStateful = props => {
|
|
|
749
755
|
}
|
|
750
756
|
}
|
|
751
757
|
`), /*#__PURE__*/React.createElement(DraggableChatWidget, chatWidgetDraggableConfig, /*#__PURE__*/React.createElement(Composer, _extends({}, webChatProps, {
|
|
758
|
+
userID: userID,
|
|
752
759
|
styleOptions: {
|
|
753
760
|
...webChatStyles,
|
|
754
761
|
bubbleBackground: ((_props$webChatContain9 = props.webChatContainerProps) === null || _props$webChatContain9 === void 0 ? void 0 : (_props$webChatContain10 = _props$webChatContain9.adaptiveCardStyles) === null || _props$webChatContain10 === void 0 ? void 0 : _props$webChatContain10.background) ?? defaultAdaptiveCardStyles.background,
|
|
755
762
|
bubbleTextColor: ((_props$webChatContain11 = props.webChatContainerProps) === null || _props$webChatContain11 === void 0 ? void 0 : (_props$webChatContain12 = _props$webChatContain11.adaptiveCardStyles) === null || _props$webChatContain12 === void 0 ? void 0 : _props$webChatContain12.color) ?? defaultAdaptiveCardStyles.color
|
|
756
763
|
},
|
|
757
|
-
directLine:
|
|
764
|
+
directLine: directLine
|
|
758
765
|
}), /*#__PURE__*/React.createElement(Stack, {
|
|
759
766
|
id: widgetElementId,
|
|
760
767
|
styles: generalStyles,
|
|
@@ -43,3 +43,4 @@ export declare const createFileAndDownload: (fileName: string, blobData: string,
|
|
|
43
43
|
*/
|
|
44
44
|
export declare const formatTemplateString: (templateMessage: string, values: any) => string;
|
|
45
45
|
export declare const parseLowerCaseString: (property: string | boolean | undefined) => string;
|
|
46
|
+
export declare const setOcUserAgent: (chatSDK: any) => void;
|
package/lib/types/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { ILiveChatWidgetProps } from "../interfaces/ILiveChatWidgetProps";
|
|
2
|
-
export declare const LiveChatWidgetStateful: (props: ILiveChatWidgetProps) =>
|
|
2
|
+
export declare const LiveChatWidgetStateful: (props: ILiveChatWidgetProps) => any;
|
|
3
3
|
export default LiveChatWidgetStateful;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@microsoft/omnichannel-chat-widget",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.6-main.a655e3b",
|
|
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.8.
|
|
78
|
+
"@microsoft/omnichannel-chat-sdk": "^1.8.3",
|
|
79
79
|
"abort-controller-es5": "^2.0.1",
|
|
80
80
|
"dompurify": "^2.3.4",
|
|
81
81
|
"markdown-it": "^12.3.2",
|
|
@@ -85,8 +85,8 @@
|
|
|
85
85
|
"md5-typescript": "^1.0.5",
|
|
86
86
|
"p-defer-es5": "^2.0.1",
|
|
87
87
|
"sanitize-html": "2.12.1",
|
|
88
|
-
"
|
|
89
|
-
"
|
|
88
|
+
"simple-update-in": "2.2.0",
|
|
89
|
+
"slack-markdown-it": "^1.0.5"
|
|
90
90
|
},
|
|
91
91
|
"scripts": {
|
|
92
92
|
"storybook": "start-storybook -p 6006",
|