@xapp/chat-widget 1.56.0 → 1.57.2
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/dist/components/ChatWidget/ChatWidget.stories.d.ts +3 -1
- package/dist/index.css +2 -2
- package/dist/index.es.js +31 -16
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +31 -16
- package/dist/index.js.map +1 -1
- package/dist/xapp/StentorDirectChat.d.ts +0 -0
- package/dist/xapp-chat-widget.css +1 -1
- package/dist/xapp-chat-widget.js +2 -2
- package/dist/xapp-chat-widget.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -470,7 +470,7 @@ function getLeftArrowSvg() {
|
|
|
470
470
|
React__default$1["default"].createElement("path", { d: "M 2.5 -15 L -2.5 0 L 2.5 15", stroke: "currentColor", strokeLinecap: "square", strokeWidth: "4px", fill: "none" })));
|
|
471
471
|
}
|
|
472
472
|
var ChevronLeft = function (props) {
|
|
473
|
-
return (React__default$1["default"].createElement("button", { onClick: props.onClick, className: "chevron" }, getLeftArrowSvg()));
|
|
473
|
+
return (React__default$1["default"].createElement("button", { onClick: props.onClick, className: "xa-chevron" }, getLeftArrowSvg()));
|
|
474
474
|
};
|
|
475
475
|
|
|
476
476
|
function getRightArrowSvg() {
|
|
@@ -478,7 +478,7 @@ function getRightArrowSvg() {
|
|
|
478
478
|
React__default$1["default"].createElement("path", { d: "M -2.5 -15 L 2.5 0 L -2.5 15", stroke: "currentColor", strokeLinecap: "square", strokeWidth: "4px", fill: "none" })));
|
|
479
479
|
}
|
|
480
480
|
var ChevronRight = function (props) {
|
|
481
|
-
return (React__default$1["default"].createElement("button", { onClick: props.onClick, className: "chevron" }, getRightArrowSvg()));
|
|
481
|
+
return (React__default$1["default"].createElement("button", { onClick: props.onClick, className: "xa-chevron" }, getRightArrowSvg()));
|
|
482
482
|
};
|
|
483
483
|
|
|
484
484
|
var Carousel = function (props) {
|
|
@@ -2304,7 +2304,8 @@ var StentorDirectChat = /** @class */ (function () {
|
|
|
2304
2304
|
_f.label = 1;
|
|
2305
2305
|
case 1:
|
|
2306
2306
|
if (!(i < configurableMessages.length)) return [3 /*break*/, 4];
|
|
2307
|
-
timeout =
|
|
2307
|
+
timeout = this.config.timeout || 15000;
|
|
2308
|
+
console.log("using timeout of ".concat(timeout));
|
|
2308
2309
|
this.typing();
|
|
2309
2310
|
// We don't start typing IF we have a failure message displayed and we are waiting on the timeout
|
|
2310
2311
|
return [4 /*yield*/, new RetryRequest({ retries: 1, timeout: timeout })
|
|
@@ -2570,7 +2571,7 @@ function requestToMessage(botRequest, now) {
|
|
|
2570
2571
|
|
|
2571
2572
|
var StentorRouterChat = /** @class */ (function () {
|
|
2572
2573
|
function StentorRouterChat(config, options) {
|
|
2573
|
-
var _a;
|
|
2574
|
+
var _a, _b;
|
|
2574
2575
|
this._userId = "";
|
|
2575
2576
|
this._sessionId = "";
|
|
2576
2577
|
this.accessToken = "";
|
|
@@ -2583,13 +2584,23 @@ var StentorRouterChat = /** @class */ (function () {
|
|
|
2583
2584
|
// Dig out the path parameters. Put them into the attributes.
|
|
2584
2585
|
// The WS url is the barebone domain.
|
|
2585
2586
|
var url = new URL(this.config.url);
|
|
2586
|
-
var
|
|
2587
|
+
var appId = url.searchParams.get("appId");
|
|
2587
2588
|
var locationUrl = new URL(window.location.href);
|
|
2588
2589
|
this.isAdmin = locationUrl.searchParams.get("isAdmin") === "true";
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
this.serverUrl =
|
|
2592
|
-
this.urlAttributes.path =
|
|
2590
|
+
if (appId) {
|
|
2591
|
+
// New Path if we have the appId on the query string
|
|
2592
|
+
this.serverUrl = this.config.url;
|
|
2593
|
+
this.urlAttributes.path = (_a = url.pathname) === null || _a === void 0 ? void 0 : _a.split("/");
|
|
2594
|
+
// keep the server url
|
|
2595
|
+
}
|
|
2596
|
+
else {
|
|
2597
|
+
// Old path
|
|
2598
|
+
this.serverUrl = "".concat(url.origin);
|
|
2599
|
+
var urlPath = (_b = url.pathname) === null || _b === void 0 ? void 0 : _b.split("/");
|
|
2600
|
+
if (urlPath && urlPath.length > 1) {
|
|
2601
|
+
this.serverUrl = "".concat(this.serverUrl, "/").concat(urlPath[1]);
|
|
2602
|
+
this.urlAttributes.path = urlPath.slice(1);
|
|
2603
|
+
}
|
|
2593
2604
|
}
|
|
2594
2605
|
log("WS url: ".concat(this.serverUrl, " isAdmin: ").concat(this.isAdmin, " attributes: ").concat(JSON.stringify(this.attributes)));
|
|
2595
2606
|
this.configurableMessages = getConfigurableMessagesConfig(options.configurableMessages);
|
|
@@ -2757,7 +2768,10 @@ var StentorRouterChat = /** @class */ (function () {
|
|
|
2757
2768
|
StentorRouterChat.prototype.wsCreate = function () {
|
|
2758
2769
|
var _this = this;
|
|
2759
2770
|
this.setConnectionStatus("pending");
|
|
2760
|
-
|
|
2771
|
+
var url = new URL(this.serverUrl);
|
|
2772
|
+
url.searchParams.set("userId", this._userId);
|
|
2773
|
+
url.searchParams.set("isAdmin", "".concat(this.isAdmin));
|
|
2774
|
+
this.ws = new WebSocket(url.toString());
|
|
2761
2775
|
this.ws.onerror = function (ev) {
|
|
2762
2776
|
var _a;
|
|
2763
2777
|
log("Error in WS connection. Type: ".concat(!ev ? "?" : ev.type, " Ready State: ").concat((_a = _this.ws) === null || _a === void 0 ? void 0 : _a.readyState));
|
|
@@ -6572,7 +6586,8 @@ function createChatServerCore(config, options) {
|
|
|
6572
6586
|
case "direct":
|
|
6573
6587
|
return new StentorDirectChat({
|
|
6574
6588
|
url: config.serverUrl,
|
|
6575
|
-
key: config.accountKey
|
|
6589
|
+
key: config.accountKey,
|
|
6590
|
+
timeout: config.timeout
|
|
6576
6591
|
}, options);
|
|
6577
6592
|
case "websocket":
|
|
6578
6593
|
return new StentorServerChat({
|
|
@@ -30277,14 +30292,14 @@ var MessageList = function (props) {
|
|
|
30277
30292
|
* @param addClass
|
|
30278
30293
|
*/
|
|
30279
30294
|
function renderByType(msg, sibling) {
|
|
30280
|
-
var _a;
|
|
30295
|
+
var _a, _b, _c;
|
|
30281
30296
|
var user;
|
|
30282
30297
|
// visitor is this widget
|
|
30283
|
-
if (msg.user.nick.startsWith("visitor:")) {
|
|
30298
|
+
if ((_b = (_a = msg.user) === null || _a === void 0 ? void 0 : _a.nick) === null || _b === void 0 ? void 0 : _b.startsWith("visitor:")) {
|
|
30284
30299
|
user = msg.user;
|
|
30285
30300
|
}
|
|
30286
30301
|
else {
|
|
30287
|
-
user = ((
|
|
30302
|
+
user = ((_c = props.agents[msg.user.nick]) === null || _c === void 0 ? void 0 : _c.user) || props.agent;
|
|
30288
30303
|
// Still nothing?
|
|
30289
30304
|
if (!user) {
|
|
30290
30305
|
log("Could not get a user from agents list with nick: \"".concat(msg.user.nick, "\""));
|
|
@@ -30978,8 +30993,8 @@ var ChatWidget = function (props) {
|
|
|
30978
30993
|
React__default$1["default"].createElement(WidgetStylesheet, { theme: config === null || config === void 0 ? void 0 : config.theme }),
|
|
30979
30994
|
React__default$1["default"].createElement(ChatHeader, { accountStatus: chatState.accountStatus, refreshOnClick: openModal, minimizeOnClick: minimizeOnClick, cancelOnClick: cancelOnClick, agent: widgetAgent, canRefresh: canRefresh, canMinimize: canMinimize, canCancel: canCancel, config: config === null || config === void 0 ? void 0 : config.header, menuConfig: config.menu, onSubmit: handleOnSubmit }),
|
|
30980
30995
|
React__default$1["default"].createElement(MessageList, { visible: visible, queuePosition: chatState.queuePosition, isChatting: chatState.isChatting, isOffline: isOffline, messages: messages, agents: chatState.agents, agent: config === null || config === void 0 ? void 0 : config.agent, lastRatingRequestTimestamp: chatState.lastRatingRequestTimestamp, hasRating: chatState.hasRating, visitorId: chatState.visitorId, messageMiddleware: props.messageMiddleware, textTypingStatusEnabled: (_u = (_t = props.config) === null || _t === void 0 ? void 0 : _t.typingStatus) === null || _u === void 0 ? void 0 : _u.textTypingStatusEnabled, onSend: handleSendMessage, onWrite: handleWriteMessage, onOpenUrl: handleOpenUrl }),
|
|
30981
|
-
React__default$1["default"].createElement("div", { className: "spinner-container ".concat(visible && connectionStatus === "pending" ? "visible" : "") },
|
|
30982
|
-
React__default$1["default"].createElement("div", { className: "spinner" })),
|
|
30996
|
+
React__default$1["default"].createElement("div", { className: "xa-spinner-container ".concat(visible && connectionStatus === "pending" ? "visible" : "") },
|
|
30997
|
+
React__default$1["default"].createElement("div", { className: "xa-spinner" })),
|
|
30983
30998
|
connectionStatus === "offline" && React__default$1["default"].createElement(ServerOffline, null),
|
|
30984
30999
|
React__default$1["default"].createElement(ChatFooter, { isAdmin: config === null || config === void 0 ? void 0 : config.isAdmin, isChatting: chatState.isChatting, placeholder: (_v = config === null || config === void 0 ? void 0 : config.input) === null || _v === void 0 ? void 0 : _v.placeholder, sendButtonIcon: (_x = (_w = config === null || config === void 0 ? void 0 : config.footer) === null || _w === void 0 ? void 0 : _w.sendButton) === null || _x === void 0 ? void 0 : _x.icon, visible: visible, menuConfig: props.config.menu, footerConfig: (_y = props.config) === null || _y === void 0 ? void 0 : _y.footer, inputConfig: (_z = props.config) === null || _z === void 0 ? void 0 : _z.input, onChange: handleOnChange, onSubmit: handleOnSubmit, onFileUpload: handleFileUpload }),
|
|
30985
31000
|
React__default$1["default"].createElement("div", { className: "restartModal", ref: modalRef, onClick: closeModal },
|