@botpress/webchat 0.5.1 → 1.0.0
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/App.d.ts +10 -0
- package/dist/Utils/colors.d.ts +18 -0
- package/dist/Utils/eventEmitter.d.ts +12 -0
- package/dist/Utils/index.d.ts +2 -0
- package/dist/client/MessagingClient.d.ts +27 -0
- package/dist/client/adapters/Audio.d.ts +19 -0
- package/dist/client/adapters/Card.d.ts +188 -0
- package/dist/client/adapters/Carousel.d.ts +147 -0
- package/dist/client/adapters/Choice.d.ts +45 -0
- package/dist/client/adapters/Dropdown.d.ts +46 -0
- package/dist/client/adapters/File.d.ts +19 -0
- package/dist/client/adapters/Image.d.ts +19 -0
- package/dist/client/adapters/Location.d.ts +27 -0
- package/dist/client/adapters/Message.d.ts +433 -0
- package/dist/client/adapters/Text.d.ts +20 -0
- package/dist/client/adapters/Utils.d.ts +5 -0
- package/dist/client/adapters/Video.d.ts +19 -0
- package/dist/client/adapters/Voice.d.ts +15 -0
- package/dist/client/adapters/index.d.ts +12 -0
- package/dist/client/index.d.ts +2 -0
- package/dist/components/Avatar.d.ts +6 -0
- package/dist/components/Block.d.ts +4 -0
- package/dist/components/Composer.d.ts +12 -14
- package/dist/components/Container.d.ts +2 -12
- package/dist/components/Header.d.ts +36 -26
- package/dist/components/LoadingIndicator.d.ts +2 -0
- package/dist/components/Message.d.ts +7 -0
- package/dist/components/MessageList.d.ts +2 -0
- package/dist/components/Modal.d.ts +17 -0
- package/dist/components/RestartConversation.d.ts +5 -0
- package/dist/components/Webchat.d.ts +6 -0
- package/dist/components/dev-tools/DevTools.d.ts +1 -0
- package/dist/components/dev-tools/configuration.d.ts +2 -0
- package/dist/components/dev-tools/helpers.d.ts +5 -0
- package/dist/components/index.d.ts +12 -0
- package/dist/components/renderers/Audio.d.ts +3 -0
- package/dist/components/renderers/Bubble.d.ts +5 -0
- package/dist/components/renderers/Button.d.ts +4 -0
- package/dist/components/renderers/Carousel.d.ts +3 -0
- package/dist/components/renderers/Column.d.ts +5 -0
- package/dist/components/renderers/Dropdown.d.ts +5 -0
- package/dist/components/renderers/File.d.ts +3 -0
- package/dist/components/renderers/Image.d.ts +3 -0
- package/dist/components/renderers/Location.d.ts +3 -0
- package/dist/components/renderers/Row.d.ts +5 -0
- package/dist/components/renderers/Text.d.ts +4 -0
- package/dist/components/renderers/Video.d.ts +3 -0
- package/dist/components/renderers/index.d.ts +2 -0
- package/dist/contexts/ComposerContext.d.ts +8 -0
- package/dist/contexts/MessageContext.d.ts +8 -0
- package/dist/contexts/ModalContext.d.ts +14 -0
- package/dist/contexts/WebchatContext.d.ts +56 -0
- package/dist/contexts/index.d.ts +4 -0
- package/dist/hooks/index.d.ts +3 -0
- package/dist/hooks/useImageSize.d.ts +2 -0
- package/dist/hooks/useRefresh.d.ts +10 -0
- package/dist/hooks/useWebchatStore.d.ts +30 -0
- package/dist/index.d.ts +3 -17
- package/dist/index.js +43569 -48
- package/dist/index.umd.cjs +702 -0
- package/dist/main.d.ts +11 -13
- package/dist/providers/ModalProvider.d.ts +8 -0
- package/dist/providers/WebchatProvider.d.ts +13 -0
- package/dist/providers/index.d.ts +2 -0
- package/dist/schemas/index.d.ts +1 -0
- package/dist/schemas/theme.d.ts +3371 -0
- package/dist/services/clipboard.d.ts +1 -0
- package/dist/services/images.d.ts +2 -0
- package/dist/services/index.d.ts +3 -0
- package/dist/services/toast.d.ts +17 -0
- package/dist/themes/dawn.d.ts +2 -0
- package/dist/themes/duskTheme.d.ts +2 -0
- package/dist/themes/eggplant.d.ts +2 -0
- package/dist/themes/galaxy.d.ts +2 -0
- package/dist/themes/index.d.ts +6 -0
- package/dist/themes/midnight.d.ts +2 -0
- package/dist/themes/prism.d.ts +2 -0
- package/dist/twind.config.d.ts +9 -0
- package/dist/types/block-type.d.ts +93 -0
- package/dist/types/image.d.ts +11 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/vite.svg +1 -0
- package/index.html +18 -0
- package/package.json +60 -49
- package/public/vite.svg +1 -0
- package/src/App.tsx +41 -0
- package/src/Utils/colors.ts +45 -0
- package/src/Utils/eventEmitter.ts +31 -0
- package/src/Utils/index.ts +2 -0
- package/src/assets/check-circle-bold.svg +5 -0
- package/src/assets/chevron-up.svg +3 -0
- package/src/assets/file-05.svg +6 -0
- package/src/assets/globe-02.svg +6 -0
- package/src/assets/help-circle.svg +3 -0
- package/src/assets/info-circle.svg +3 -0
- package/src/assets/lock-01.svg +4 -0
- package/src/assets/mail-01.svg +6 -0
- package/src/assets/minus-circle.svg +3 -0
- package/src/assets/phone.svg +6 -0
- package/src/assets/send-03.svg +4 -0
- package/src/assets/share-04.svg +5 -0
- package/src/assets/slash-circle-01.svg +3 -0
- package/src/assets/x-circle-bold.svg +5 -0
- package/src/assets/x-close.svg +3 -0
- package/src/assets/x.svg +3 -0
- package/src/client/MessagingClient.ts +87 -0
- package/src/client/adapters/Audio.ts +10 -0
- package/src/client/adapters/Card.ts +104 -0
- package/src/client/adapters/Carousel.ts +11 -0
- package/src/client/adapters/Choice.ts +48 -0
- package/src/client/adapters/Dropdown.ts +39 -0
- package/src/client/adapters/File.ts +10 -0
- package/src/client/adapters/Image.ts +10 -0
- package/src/client/adapters/Location.ts +18 -0
- package/src/client/adapters/Message.ts +26 -0
- package/src/client/adapters/Text.ts +11 -0
- package/src/client/adapters/Utils.ts +11 -0
- package/src/client/adapters/Video.ts +10 -0
- package/src/client/adapters/Voice.ts +9 -0
- package/src/client/adapters/index.ts +12 -0
- package/src/client/index.ts +2 -0
- package/src/components/Avatar.tsx +22 -0
- package/src/components/Block.tsx +17 -0
- package/src/components/Composer.tsx +115 -0
- package/src/components/Container.tsx +17 -0
- package/src/components/Header.tsx +141 -0
- package/src/components/LoadingIndicator.tsx +15 -0
- package/src/components/Message.tsx +52 -0
- package/src/components/MessageList.tsx +75 -0
- package/src/components/Modal.tsx +49 -0
- package/src/components/RestartConversation.tsx +52 -0
- package/src/components/Webchat.tsx +68 -0
- package/src/components/dev-tools/DevTools.tsx +496 -0
- package/src/components/dev-tools/configuration.tsx +27 -0
- package/src/components/dev-tools/helpers.ts +21 -0
- package/src/components/index.ts +12 -0
- package/src/components/renderers/Audio.tsx +11 -0
- package/src/components/renderers/Bubble.tsx +12 -0
- package/src/components/renderers/Button.tsx +59 -0
- package/src/components/renderers/Carousel.tsx +51 -0
- package/src/components/renderers/Column.tsx +22 -0
- package/src/components/renderers/Dropdown.tsx +170 -0
- package/src/components/renderers/File.tsx +13 -0
- package/src/components/renderers/Image.tsx +63 -0
- package/src/components/renderers/Location.tsx +16 -0
- package/src/components/renderers/Row.tsx +22 -0
- package/src/components/renderers/Text.tsx +32 -0
- package/src/components/renderers/Video.tsx +11 -0
- package/src/components/renderers/index.ts +28 -0
- package/src/contexts/ComposerContext.ts +16 -0
- package/src/contexts/MessageContext.ts +16 -0
- package/src/contexts/ModalContext.ts +19 -0
- package/src/contexts/WebchatContext.ts +61 -0
- package/src/contexts/index.ts +4 -0
- package/src/hooks/index.ts +3 -0
- package/src/hooks/useImageSize.ts +30 -0
- package/src/hooks/useRefresh.ts +33 -0
- package/src/hooks/useWebchatStore.ts +45 -0
- package/src/index.css +18 -0
- package/src/index.ts +3 -0
- package/src/main.tsx +33 -0
- package/src/providers/ModalProvider.tsx +35 -0
- package/src/providers/WebchatProvider.tsx +107 -0
- package/src/providers/index.ts +2 -0
- package/src/schemas/index.ts +1 -0
- package/src/schemas/theme.ts +188 -0
- package/src/services/clipboard.ts +8 -0
- package/src/services/images.ts +39 -0
- package/src/services/index.ts +3 -0
- package/src/services/toast.tsx +71 -0
- package/src/themes/dawn.ts +277 -0
- package/src/themes/duskTheme.ts +349 -0
- package/src/themes/eggplant.ts +353 -0
- package/src/themes/galaxy.ts +323 -0
- package/src/themes/index.ts +6 -0
- package/src/themes/midnight.ts +276 -0
- package/src/themes/prism.ts +349 -0
- package/src/twind.config.ts +31 -0
- package/src/types/block-type.ts +150 -0
- package/src/types/image.ts +10 -0
- package/src/types/index.ts +2 -0
- package/src/vite-env.d.ts +1 -0
- package/tailwind.config.js +0 -0
- package/tsconfig.json +30 -0
- package/tsconfig.node.json +10 -0
- package/vite.config.ts +31 -0
- package/README.md +0 -41
- package/assets/fonts/roboto/roboto.woff2 +0 -0
- package/assets/fonts/roboto/roboto500.woff2 +0 -0
- package/assets/fonts/roboto.css +0 -128
- package/assets/notification.mp3 +0 -0
- package/dist/components/Composer.js +0 -118
- package/dist/components/Container.js +0 -62
- package/dist/components/ConversationList.d.ts +0 -10
- package/dist/components/ConversationList.js +0 -41
- package/dist/components/Footer.d.ts +0 -3
- package/dist/components/Footer.js +0 -21
- package/dist/components/Header.js +0 -181
- package/dist/components/VoiceRecorder.d.ts +0 -10
- package/dist/components/VoiceRecorder.js +0 -137
- package/dist/components/common/Avatar/index.d.ts +0 -9
- package/dist/components/common/Avatar/index.js +0 -13
- package/dist/components/common/BotInfo/index.d.ts +0 -10
- package/dist/components/common/BotInfo/index.js +0 -107
- package/dist/components/common/BotInfo/style.scss +0 -88
- package/dist/components/common/ConfirmDialog/index.d.ts +0 -11
- package/dist/components/common/ConfirmDialog/index.js +0 -78
- package/dist/components/common/ConfirmDialog/style.module.scss +0 -48
- package/dist/components/common/Dialog/index.d.ts +0 -17
- package/dist/components/common/Dialog/index.js +0 -57
- package/dist/components/common/Dialog/style.module.scss +0 -29
- package/dist/components/common/ToolTip/index.d.ts +0 -10
- package/dist/components/common/ToolTip/index.js +0 -163
- package/dist/components/common/ToolTip/style.module.scss +0 -108
- package/dist/components/common/ToolTip/utils.d.ts +0 -15
- package/dist/components/common/ToolTip/utils.js +0 -78
- package/dist/components/common/variables.scss +0 -38
- package/dist/components/messages/InlineFeedback.d.ts +0 -11
- package/dist/components/messages/InlineFeedback.js +0 -56
- package/dist/components/messages/Message.d.ts +0 -11
- package/dist/components/messages/Message.js +0 -106
- package/dist/components/messages/MessageGroup.d.ts +0 -23
- package/dist/components/messages/MessageGroup.js +0 -63
- package/dist/components/messages/MessageList.d.ts +0 -10
- package/dist/components/messages/MessageList.js +0 -148
- package/dist/core/api.d.ts +0 -23
- package/dist/core/api.js +0 -117
- package/dist/core/constants.d.ts +0 -14
- package/dist/core/constants.js +0 -29
- package/dist/core/socket.d.ts +0 -14
- package/dist/core/socket.js +0 -57
- package/dist/declaration.d.ts +0 -2
- package/dist/declaration.js +0 -1
- package/dist/fonts/roboto.d.ts +0 -4
- package/dist/fonts/roboto.js +0 -9
- package/dist/globals.d.ts +0 -7
- package/dist/globals.js +0 -2
- package/dist/icons/Add.d.ts +0 -6
- package/dist/icons/Add.js +0 -10
- package/dist/icons/Cancel.d.ts +0 -5
- package/dist/icons/Cancel.js +0 -10
- package/dist/icons/Chat.d.ts +0 -6
- package/dist/icons/Chat.js +0 -9
- package/dist/icons/Close.d.ts +0 -3
- package/dist/icons/Close.js +0 -10
- package/dist/icons/Delete.d.ts +0 -3
- package/dist/icons/Delete.js +0 -11
- package/dist/icons/Download.d.ts +0 -3
- package/dist/icons/Download.js +0 -10
- package/dist/icons/Email.d.ts +0 -3
- package/dist/icons/Email.js +0 -8
- package/dist/icons/Information.d.ts +0 -3
- package/dist/icons/Information.js +0 -12
- package/dist/icons/List.d.ts +0 -3
- package/dist/icons/List.js +0 -15
- package/dist/icons/Microphone.d.ts +0 -5
- package/dist/icons/Microphone.js +0 -12
- package/dist/icons/Phone.d.ts +0 -3
- package/dist/icons/Phone.js +0 -8
- package/dist/icons/Reload.d.ts +0 -3
- package/dist/icons/Reload.js +0 -10
- package/dist/icons/ThumbsDown.d.ts +0 -3
- package/dist/icons/ThumbsDown.js +0 -11
- package/dist/icons/ThumbsUp.d.ts +0 -3
- package/dist/icons/ThumbsUp.js +0 -11
- package/dist/icons/Website.d.ts +0 -3
- package/dist/icons/Website.js +0 -8
- package/dist/main.js +0 -336
- package/dist/store/composer.d.ts +0 -17
- package/dist/store/composer.js +0 -98
- package/dist/store/index.d.ts +0 -89
- package/dist/store/index.js +0 -604
- package/dist/store/view.d.ts +0 -61
- package/dist/store/view.js +0 -365
- package/dist/translations/ar.json +0 -30
- package/dist/translations/de.json +0 -32
- package/dist/translations/en.json +0 -40
- package/dist/translations/es.json +0 -19
- package/dist/translations/fr.json +0 -40
- package/dist/translations/index.d.ts +0 -9
- package/dist/translations/index.js +0 -95
- package/dist/translations/it.json +0 -38
- package/dist/translations/pt.json +0 -19
- package/dist/translations/ru.json +0 -24
- package/dist/translations/uk.json +0 -24
- package/dist/typings.d.ts +0 -410
- package/dist/typings.js +0 -2
- package/dist/utils/analytics.d.ts +0 -5
- package/dist/utils/analytics.js +0 -37
- package/dist/utils/index.d.ts +0 -3
- package/dist/utils/index.js +0 -27
- package/dist/utils/storage.d.ts +0 -16
- package/dist/utils/storage.js +0 -129
- package/dist/utils/webchatEvents.d.ts +0 -2
- package/dist/utils/webchatEvents.js +0 -14
package/dist/store/index.js
DELETED
|
@@ -1,604 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
9
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
10
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
11
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
12
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
13
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
14
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
15
|
-
});
|
|
16
|
-
};
|
|
17
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
|
-
};
|
|
20
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.RootStore = void 0;
|
|
22
|
-
const axios_1 = __importDefault(require("axios"));
|
|
23
|
-
const is_before_1 = __importDefault(require("date-fns/is_before"));
|
|
24
|
-
const is_valid_1 = __importDefault(require("date-fns/is_valid"));
|
|
25
|
-
const merge_1 = __importDefault(require("lodash/merge"));
|
|
26
|
-
const orderBy_1 = __importDefault(require("lodash/orderBy"));
|
|
27
|
-
const mobx_1 = require("mobx");
|
|
28
|
-
const api_1 = __importDefault(require("../core/api"));
|
|
29
|
-
const main_1 = require("../main");
|
|
30
|
-
const translations_1 = require("../translations");
|
|
31
|
-
const utils_1 = require("../utils");
|
|
32
|
-
const analytics_1 = require("../utils/analytics");
|
|
33
|
-
const webchatEvents_1 = require("../utils/webchatEvents");
|
|
34
|
-
const composer_1 = __importDefault(require("./composer"));
|
|
35
|
-
const view_1 = __importDefault(require("./view"));
|
|
36
|
-
class RootStore {
|
|
37
|
-
constructor(options, config) {
|
|
38
|
-
this.conversations = [];
|
|
39
|
-
this.isBotTyping = mobx_1.observable.box(false);
|
|
40
|
-
this.delayedMessages = [];
|
|
41
|
-
this.composer = new composer_1.default(this);
|
|
42
|
-
this.view = new view_1.default(this, options.fullscreen);
|
|
43
|
-
if (config) {
|
|
44
|
-
this.updateConfig(config);
|
|
45
|
-
}
|
|
46
|
-
this.botUILanguage = (0, translations_1.getUserLocale)();
|
|
47
|
-
}
|
|
48
|
-
setIntlProvider(provider) {
|
|
49
|
-
this.intl = provider;
|
|
50
|
-
}
|
|
51
|
-
setSocket(socket) {
|
|
52
|
-
this.api = new api_1.default(socket);
|
|
53
|
-
}
|
|
54
|
-
setSelectedMessage(messageId) {
|
|
55
|
-
this.selectedMessageId = messageId;
|
|
56
|
-
}
|
|
57
|
-
get isConversationStarted() {
|
|
58
|
-
var _a;
|
|
59
|
-
return !!((_a = this.currentConversation) === null || _a === void 0 ? void 0 : _a.messages.length);
|
|
60
|
-
}
|
|
61
|
-
get botName() {
|
|
62
|
-
var _a, _b;
|
|
63
|
-
return ((_a = this.config) === null || _a === void 0 ? void 0 : _a.botName) || ((_b = this.botInfo) === null || _b === void 0 ? void 0 : _b.name) || 'Bot';
|
|
64
|
-
}
|
|
65
|
-
get hasBotInfoDescription() {
|
|
66
|
-
var _a;
|
|
67
|
-
return !!((_a = this.config.botConversationDescription) === null || _a === void 0 ? void 0 : _a.length);
|
|
68
|
-
}
|
|
69
|
-
get botAvatarUrl() {
|
|
70
|
-
var _a, _b, _c;
|
|
71
|
-
return ((_b = (_a = this.botInfo) === null || _a === void 0 ? void 0 : _a.details) === null || _b === void 0 ? void 0 : _b.avatarUrl) || ((_c = this.config) === null || _c === void 0 ? void 0 : _c.avatarUrl) || undefined;
|
|
72
|
-
}
|
|
73
|
-
get coverPictureUrl() {
|
|
74
|
-
var _a, _b, _c, _d;
|
|
75
|
-
return (_c = (_b = (_a = this.botInfo) === null || _a === void 0 ? void 0 : _a.details) === null || _b === void 0 ? void 0 : _b.coverPictureUrl) !== null && _c !== void 0 ? _c : (_d = this.config) === null || _d === void 0 ? void 0 : _d.coverPictureUrl;
|
|
76
|
-
}
|
|
77
|
-
get description() {
|
|
78
|
-
var _a;
|
|
79
|
-
return (_a = this.config) === null || _a === void 0 ? void 0 : _a.botConversationDescription;
|
|
80
|
-
}
|
|
81
|
-
get website() {
|
|
82
|
-
var _a, _b, _c, _d;
|
|
83
|
-
return (_c = (_b = (_a = this.botInfo) === null || _a === void 0 ? void 0 : _a.details) === null || _b === void 0 ? void 0 : _b.website) !== null && _c !== void 0 ? _c : (_d = this.config) === null || _d === void 0 ? void 0 : _d.website;
|
|
84
|
-
}
|
|
85
|
-
get phoneNumber() {
|
|
86
|
-
var _a, _b, _c, _d;
|
|
87
|
-
return (_c = (_b = (_a = this.botInfo) === null || _a === void 0 ? void 0 : _a.details) === null || _b === void 0 ? void 0 : _b.phoneNumber) !== null && _c !== void 0 ? _c : (_d = this.config) === null || _d === void 0 ? void 0 : _d.phoneNumber;
|
|
88
|
-
}
|
|
89
|
-
get termsConditions() {
|
|
90
|
-
var _a, _b, _c, _d;
|
|
91
|
-
return (_c = (_b = (_a = this.botInfo) === null || _a === void 0 ? void 0 : _a.details) === null || _b === void 0 ? void 0 : _b.termsConditions) !== null && _c !== void 0 ? _c : (_d = this.config) === null || _d === void 0 ? void 0 : _d.termsConditions;
|
|
92
|
-
}
|
|
93
|
-
get privacyPolicy() {
|
|
94
|
-
var _a, _b, _c, _d;
|
|
95
|
-
return (_c = (_b = (_a = this.botInfo) === null || _a === void 0 ? void 0 : _a.details) === null || _b === void 0 ? void 0 : _b.privacyPolicy) !== null && _c !== void 0 ? _c : (_d = this.config) === null || _d === void 0 ? void 0 : _d.privacyPolicy;
|
|
96
|
-
}
|
|
97
|
-
get emailAddress() {
|
|
98
|
-
var _a, _b, _c, _d;
|
|
99
|
-
return (_c = (_b = (_a = this.botInfo) === null || _a === void 0 ? void 0 : _a.details) === null || _b === void 0 ? void 0 : _b.emailAddress) !== null && _c !== void 0 ? _c : (_d = this.config) === null || _d === void 0 ? void 0 : _d.emailAddress;
|
|
100
|
-
}
|
|
101
|
-
get rtl() {
|
|
102
|
-
return (0, translations_1.isRTLLocale)(this.preferredLanguage);
|
|
103
|
-
}
|
|
104
|
-
get escapeHTML() {
|
|
105
|
-
var _a, _b;
|
|
106
|
-
return (_b = (_a = this.botInfo) === null || _a === void 0 ? void 0 : _a.security) === null || _b === void 0 ? void 0 : _b.escapeHTML;
|
|
107
|
-
}
|
|
108
|
-
get currentMessages() {
|
|
109
|
-
var _a;
|
|
110
|
-
return ((_a = this.currentConversation) === null || _a === void 0 ? void 0 : _a.messages) || [];
|
|
111
|
-
}
|
|
112
|
-
get currentConversationId() {
|
|
113
|
-
var _a;
|
|
114
|
-
return (_a = this.currentConversation) === null || _a === void 0 ? void 0 : _a.id;
|
|
115
|
-
}
|
|
116
|
-
updateMessages(messages) {
|
|
117
|
-
if (this.currentConversation) {
|
|
118
|
-
this.currentConversation.messages = messages;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
updateLastMessage(conversationId, message) {
|
|
122
|
-
for (const conversation of this.conversations) {
|
|
123
|
-
if (conversation.id === conversationId) {
|
|
124
|
-
conversation.lastMessage = message;
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
clearMessages() {
|
|
130
|
-
if (this.currentConversation) {
|
|
131
|
-
this.currentConversation.messages = [];
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
deleteConversation() {
|
|
135
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
136
|
-
if (this.currentConversationId) {
|
|
137
|
-
yield this.api.deleteConversation(this.currentConversationId);
|
|
138
|
-
const index = this.conversations.findIndex((c) => c.id === this.currentConversationId);
|
|
139
|
-
if (index > -1) {
|
|
140
|
-
this.conversations.splice(index, 1);
|
|
141
|
-
}
|
|
142
|
-
this.resetConversation();
|
|
143
|
-
yield this.fetchConversation();
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
addEventToConversation(event) {
|
|
148
|
-
var _a;
|
|
149
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
150
|
-
if (!this.currentConversation || (this.isInitialized && this.currentConversationId !== event.conversationId)) {
|
|
151
|
-
yield this.fetchConversations();
|
|
152
|
-
yield this.fetchConversation(event.conversationId);
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
|
-
// Autoplay bot voice messages
|
|
156
|
-
if (((_a = event.payload) === null || _a === void 0 ? void 0 : _a.type) === 'voice' && !event.authorId) {
|
|
157
|
-
event.payload.autoPlay = true;
|
|
158
|
-
}
|
|
159
|
-
const message = Object.assign(Object.assign({}, event), { conversationId: event.conversationId });
|
|
160
|
-
if (this.isBotTyping.get() && !event.authorId) {
|
|
161
|
-
this.delayedMessages.push({ message, showAt: this.currentConversation.typingUntil });
|
|
162
|
-
}
|
|
163
|
-
else {
|
|
164
|
-
this.currentConversation.messages.push(message);
|
|
165
|
-
}
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
updateTyping(event) {
|
|
169
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
170
|
-
if (!this.currentConversation || (this.isInitialized && this.currentConversationId !== event.conversationId)) {
|
|
171
|
-
yield this.fetchConversations();
|
|
172
|
-
yield this.fetchConversation(event.conversationId);
|
|
173
|
-
return;
|
|
174
|
-
}
|
|
175
|
-
let start = new Date();
|
|
176
|
-
if ((0, is_before_1.default)(start, this.currentConversation.typingUntil)) {
|
|
177
|
-
start = this.currentConversation.typingUntil;
|
|
178
|
-
}
|
|
179
|
-
this.currentConversation.typingUntil = new Date(+start + (event.timeInMs || main_1.DEFAULT_TYPING_DELAY));
|
|
180
|
-
this._startTypingTimer();
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
/** Loads the initial state, for the first time or when the user ID is changed. */
|
|
184
|
-
initializeChat() {
|
|
185
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
186
|
-
try {
|
|
187
|
-
yield this.fetchConversations();
|
|
188
|
-
yield this.fetchConversation();
|
|
189
|
-
(0, mobx_1.runInAction)('-> setInitialized', () => {
|
|
190
|
-
this.isInitialized = true;
|
|
191
|
-
(0, webchatEvents_1.postMessageToParent)('LIFECYCLE.READY', undefined, this.config.chatId);
|
|
192
|
-
});
|
|
193
|
-
}
|
|
194
|
-
catch (err) {
|
|
195
|
-
console.error('Error while fetching data, creating new conversation...', err);
|
|
196
|
-
yield this.createConversation();
|
|
197
|
-
}
|
|
198
|
-
this.fetchLanguage();
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
fetchBotInfo() {
|
|
202
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
203
|
-
if (!this.config.mediaFileServiceUrl) {
|
|
204
|
-
return;
|
|
205
|
-
}
|
|
206
|
-
try {
|
|
207
|
-
const { data } = yield axios_1.default.get(this.config.mediaFileServiceUrl);
|
|
208
|
-
if (!data) {
|
|
209
|
-
return;
|
|
210
|
-
}
|
|
211
|
-
(0, mobx_1.runInAction)('-> setBotInfo', () => {
|
|
212
|
-
this.botInfo = data;
|
|
213
|
-
});
|
|
214
|
-
this.mergeConfig({
|
|
215
|
-
disableNotificationSound: data.disableNotificationSound
|
|
216
|
-
});
|
|
217
|
-
}
|
|
218
|
-
catch (err) {
|
|
219
|
-
console.error('Error while loading bot info', err);
|
|
220
|
-
}
|
|
221
|
-
});
|
|
222
|
-
}
|
|
223
|
-
fetchLanguage() {
|
|
224
|
-
const language = (0, translations_1.getUserLocale)(this.config.locale);
|
|
225
|
-
(0, mobx_1.runInAction)('-> setPreferredLanguage', () => {
|
|
226
|
-
this.updateBotUILanguage(language);
|
|
227
|
-
});
|
|
228
|
-
}
|
|
229
|
-
/** Fetches the list of conversation, and update the corresponding config values */
|
|
230
|
-
fetchConversations() {
|
|
231
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
232
|
-
const conversations = yield this.api.fetchConversations();
|
|
233
|
-
(0, mobx_1.runInAction)('-> setConversations', () => {
|
|
234
|
-
if (!(conversations === null || conversations === void 0 ? void 0 : conversations.length)) {
|
|
235
|
-
this.view.showBotInfo();
|
|
236
|
-
}
|
|
237
|
-
this.conversations = conversations;
|
|
238
|
-
});
|
|
239
|
-
});
|
|
240
|
-
}
|
|
241
|
-
/** Fetch the specified conversation ID, or try to fetch a valid one from the list */
|
|
242
|
-
fetchConversation(convoId) {
|
|
243
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
244
|
-
const conversationId = convoId || this._getCurrentConvoId();
|
|
245
|
-
if (!conversationId) {
|
|
246
|
-
return this.createConversation();
|
|
247
|
-
}
|
|
248
|
-
const conversation = (yield this.api.fetchConversation(convoId || this._getCurrentConvoId()));
|
|
249
|
-
if (conversation === null || conversation === void 0 ? void 0 : conversation.messages) {
|
|
250
|
-
conversation.messages = conversation.messages.sort((a, b) => new Date(a.sentOn).getTime() - new Date(b.sentOn).getTime());
|
|
251
|
-
yield this.extractFeedback(conversation.messages);
|
|
252
|
-
}
|
|
253
|
-
(0, mobx_1.runInAction)('-> setConversation', () => {
|
|
254
|
-
this.currentConversation = conversation;
|
|
255
|
-
this.view.hideConversations();
|
|
256
|
-
});
|
|
257
|
-
});
|
|
258
|
-
}
|
|
259
|
-
/** Sends the specified message, or fetch the message in the composer */
|
|
260
|
-
sendMessage(textMessage) {
|
|
261
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
262
|
-
textMessage = textMessage || this.composer.message;
|
|
263
|
-
if (!textMessage) {
|
|
264
|
-
return;
|
|
265
|
-
}
|
|
266
|
-
this.composer.updateMessage('');
|
|
267
|
-
try {
|
|
268
|
-
const message = yield this.sendData({ type: 'text', text: textMessage });
|
|
269
|
-
(0, analytics_1.trackMessage)('sent');
|
|
270
|
-
if (message) {
|
|
271
|
-
(0, webchatEvents_1.postMessageToParent)('MESSAGE.SENT', message, this.config.chatId);
|
|
272
|
-
}
|
|
273
|
-
this.composer.addMessageToHistory(textMessage);
|
|
274
|
-
}
|
|
275
|
-
catch (e) {
|
|
276
|
-
this.composer.updateMessage(textMessage);
|
|
277
|
-
console.error('Webchat cloud not send message');
|
|
278
|
-
throw e;
|
|
279
|
-
}
|
|
280
|
-
});
|
|
281
|
-
}
|
|
282
|
-
/** Sends an event to start conversation & hide the bot info page */
|
|
283
|
-
startConversation() {
|
|
284
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
285
|
-
yield this.sendData({ type: 'request_start_conversation' });
|
|
286
|
-
this.view.toggleBotInfo();
|
|
287
|
-
});
|
|
288
|
-
}
|
|
289
|
-
/** Creates a new conversation and switches to it */
|
|
290
|
-
createConversation() {
|
|
291
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
292
|
-
const newId = yield this.api.createConversation();
|
|
293
|
-
yield this.api.startConversation();
|
|
294
|
-
yield this.fetchConversations();
|
|
295
|
-
yield this.fetchConversation(newId);
|
|
296
|
-
return newId;
|
|
297
|
-
});
|
|
298
|
-
}
|
|
299
|
-
resetConversation() {
|
|
300
|
-
this.currentConversation = undefined;
|
|
301
|
-
}
|
|
302
|
-
extractFeedback(messages) {
|
|
303
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
304
|
-
const feedbackMessageIds = messages.filter((x) => x.payload && x.payload.collectFeedback).map((x) => x.id);
|
|
305
|
-
const feedbackInfo = feedbackMessageIds.map((x) => ({ messageId: x, feedback: 1 }));
|
|
306
|
-
(0, mobx_1.runInAction)('-> setFeedbackInfo', () => {
|
|
307
|
-
this.messageFeedbacks = feedbackInfo;
|
|
308
|
-
});
|
|
309
|
-
});
|
|
310
|
-
}
|
|
311
|
-
sendFeedback(feedback, messageId) {
|
|
312
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
313
|
-
yield this.api.sendFeedback(feedback, messageId);
|
|
314
|
-
});
|
|
315
|
-
}
|
|
316
|
-
downloadConversation() {
|
|
317
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
318
|
-
try {
|
|
319
|
-
const formatDate = (date) => {
|
|
320
|
-
return new Date(date).toLocaleString();
|
|
321
|
-
};
|
|
322
|
-
const conversation = this.currentConversation;
|
|
323
|
-
if (!conversation) {
|
|
324
|
-
console.warn('Cannot download the current conversation as it is undefined.');
|
|
325
|
-
return;
|
|
326
|
-
}
|
|
327
|
-
let info = `Conversation Id: ${conversation.id}\nCreated on: ${formatDate(conversation.createdOn)}\nUser: ${conversation.userId}\n-----------------`;
|
|
328
|
-
const messages = yield this.api.listCurrentConversationMessages(500);
|
|
329
|
-
for (const message of (0, orderBy_1.default)(messages, 'sentOn', 'desc')) {
|
|
330
|
-
const payload = message.payload;
|
|
331
|
-
if (payload.type === 'session_reset') {
|
|
332
|
-
continue;
|
|
333
|
-
}
|
|
334
|
-
info += `\n[${formatDate(message.sentOn)}] ${message.authorId ? 'User' : this.config.botName || 'Bot'}: Event (${payload.type}): ${payload.text ||
|
|
335
|
-
payload.audio ||
|
|
336
|
-
payload.image ||
|
|
337
|
-
payload.video ||
|
|
338
|
-
payload.file ||
|
|
339
|
-
payload.message ||
|
|
340
|
-
payload.title ||
|
|
341
|
-
''}`;
|
|
342
|
-
}
|
|
343
|
-
const blobFile = new Blob([info]);
|
|
344
|
-
(0, utils_1.downloadFile)(`conversation-${conversation.id}`, blobFile);
|
|
345
|
-
}
|
|
346
|
-
catch (err) {
|
|
347
|
-
console.error('Error trying to download conversation', err);
|
|
348
|
-
}
|
|
349
|
-
});
|
|
350
|
-
}
|
|
351
|
-
/** Sends an event or a message, depending on how the backend manages those types */
|
|
352
|
-
sendData(data) {
|
|
353
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
354
|
-
if (!this.isInitialized || !this.currentConversationId) {
|
|
355
|
-
console.warn('[webchat] Cannot send data until the webchat is ready');
|
|
356
|
-
return;
|
|
357
|
-
}
|
|
358
|
-
const message = yield this.api.sendMessage(data, this.currentConversationId);
|
|
359
|
-
this.updateLastMessage(this.currentConversationId, message);
|
|
360
|
-
return message;
|
|
361
|
-
});
|
|
362
|
-
}
|
|
363
|
-
/** Sends a message of type voice */
|
|
364
|
-
sendVoiceMessage(voice, ext) {
|
|
365
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
366
|
-
if (this.currentConversationId) {
|
|
367
|
-
return this.api.sendVoiceMessage(voice, ext, this.currentConversationId);
|
|
368
|
-
}
|
|
369
|
-
});
|
|
370
|
-
}
|
|
371
|
-
/** Use this method to replace a value or add a new config */
|
|
372
|
-
mergeConfig(config) {
|
|
373
|
-
this.config = (0, merge_1.default)(this.config, config);
|
|
374
|
-
this._applyConfig();
|
|
375
|
-
}
|
|
376
|
-
/** This replaces all the configurations by this object */
|
|
377
|
-
updateConfig(config) {
|
|
378
|
-
this.config = config;
|
|
379
|
-
this._applyConfig();
|
|
380
|
-
}
|
|
381
|
-
_applyConfig() {
|
|
382
|
-
window.BP_STORAGE.config = this.config;
|
|
383
|
-
this.config.layoutWidth && this.view.setLayoutWidth(this.config.layoutWidth);
|
|
384
|
-
this.config.containerWidth && this.view.setContainerWidth(this.config.containerWidth);
|
|
385
|
-
this.view.disableAnimations = !!this.config.disableAnimations;
|
|
386
|
-
this.config.showPoweredBy ? this.view.showPoweredBy() : this.view.hidePoweredBy();
|
|
387
|
-
document.title = this.config.botName || 'Botpress Webchat';
|
|
388
|
-
if (!this.isInitialized) {
|
|
389
|
-
window.USE_SESSION_STORAGE = !!this.config.useSessionStorage;
|
|
390
|
-
}
|
|
391
|
-
else if (window.USE_SESSION_STORAGE !== this.config.useSessionStorage) {
|
|
392
|
-
console.warn('[WebChat] "useSessionStorage" value cannot be altered once the webchat is initialized');
|
|
393
|
-
}
|
|
394
|
-
const locale = (0, translations_1.getUserLocale)(this.config.locale);
|
|
395
|
-
this.updateBotUILanguage(locale);
|
|
396
|
-
document.documentElement.setAttribute('lang', locale);
|
|
397
|
-
(0, webchatEvents_1.postMessageToParent)('CONFIG.SET', Object.assign({}, this.config), this.config.chatId);
|
|
398
|
-
}
|
|
399
|
-
updatePreferredLanguage(lang) {
|
|
400
|
-
this.preferredLanguage = lang;
|
|
401
|
-
(0, translations_1.setUserLocale)(lang);
|
|
402
|
-
}
|
|
403
|
-
/** Starts a timer to remove the typing animation when it's completed */
|
|
404
|
-
_startTypingTimer() {
|
|
405
|
-
if (this._typingInterval) {
|
|
406
|
-
return;
|
|
407
|
-
}
|
|
408
|
-
this.isBotTyping.set(true);
|
|
409
|
-
this._typingInterval = setInterval(() => {
|
|
410
|
-
var _a;
|
|
411
|
-
const typeUntil = new Date((_a = this.currentConversation) === null || _a === void 0 ? void 0 : _a.typingUntil);
|
|
412
|
-
if (!typeUntil || !(0, is_valid_1.default)(typeUntil) || (0, is_before_1.default)(typeUntil, new Date())) {
|
|
413
|
-
this._expireTyping();
|
|
414
|
-
}
|
|
415
|
-
else {
|
|
416
|
-
this.emptyDelayedMessagesQueue(false);
|
|
417
|
-
}
|
|
418
|
-
}, 50);
|
|
419
|
-
}
|
|
420
|
-
_expireTyping() {
|
|
421
|
-
this.emptyDelayedMessagesQueue(true);
|
|
422
|
-
this.isBotTyping.set(false);
|
|
423
|
-
if (this.currentConversation) {
|
|
424
|
-
this.currentConversation.typingUntil = undefined;
|
|
425
|
-
}
|
|
426
|
-
clearInterval(this._typingInterval);
|
|
427
|
-
this._typingInterval = undefined;
|
|
428
|
-
}
|
|
429
|
-
updateBotUILanguage(lang) {
|
|
430
|
-
lang = (0, translations_1.getUserLocale)(lang); // Ensure language is supported
|
|
431
|
-
(0, mobx_1.runInAction)('-> setBotUILanguage', () => {
|
|
432
|
-
this.botUILanguage = lang;
|
|
433
|
-
this.preferredLanguage = lang;
|
|
434
|
-
(0, translations_1.setUserLocale)(lang);
|
|
435
|
-
});
|
|
436
|
-
}
|
|
437
|
-
emptyDelayedMessagesQueue(removeAll) {
|
|
438
|
-
if (!this.currentConversation) {
|
|
439
|
-
return;
|
|
440
|
-
}
|
|
441
|
-
while (this.delayedMessages.length) {
|
|
442
|
-
const message = this.delayedMessages[0];
|
|
443
|
-
if (removeAll || (0, is_before_1.default)(message.showAt, new Date())) {
|
|
444
|
-
this.currentConversation.messages.push(message.message);
|
|
445
|
-
this.delayedMessages.shift();
|
|
446
|
-
}
|
|
447
|
-
else {
|
|
448
|
-
break;
|
|
449
|
-
}
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
/** Returns the current conversation ID, or the last one. */
|
|
453
|
-
_getCurrentConvoId() {
|
|
454
|
-
if (this.currentConversationId) {
|
|
455
|
-
return this.currentConversationId;
|
|
456
|
-
}
|
|
457
|
-
if (!this.conversations.length) {
|
|
458
|
-
return;
|
|
459
|
-
}
|
|
460
|
-
return this.conversations[0].id;
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
__decorate([
|
|
464
|
-
mobx_1.observable
|
|
465
|
-
], RootStore.prototype, "conversations", void 0);
|
|
466
|
-
__decorate([
|
|
467
|
-
mobx_1.observable
|
|
468
|
-
], RootStore.prototype, "currentConversation", void 0);
|
|
469
|
-
__decorate([
|
|
470
|
-
mobx_1.observable
|
|
471
|
-
], RootStore.prototype, "selectedMessageId", void 0);
|
|
472
|
-
__decorate([
|
|
473
|
-
mobx_1.observable
|
|
474
|
-
], RootStore.prototype, "botInfo", void 0);
|
|
475
|
-
__decorate([
|
|
476
|
-
mobx_1.observable
|
|
477
|
-
], RootStore.prototype, "config", void 0);
|
|
478
|
-
__decorate([
|
|
479
|
-
mobx_1.observable
|
|
480
|
-
], RootStore.prototype, "preferredLanguage", void 0);
|
|
481
|
-
__decorate([
|
|
482
|
-
mobx_1.observable
|
|
483
|
-
], RootStore.prototype, "isInitialized", void 0);
|
|
484
|
-
__decorate([
|
|
485
|
-
mobx_1.observable
|
|
486
|
-
], RootStore.prototype, "messageFeedbacks", void 0);
|
|
487
|
-
__decorate([
|
|
488
|
-
mobx_1.observable
|
|
489
|
-
], RootStore.prototype, "botUILanguage", void 0);
|
|
490
|
-
__decorate([
|
|
491
|
-
mobx_1.action.bound
|
|
492
|
-
], RootStore.prototype, "setIntlProvider", null);
|
|
493
|
-
__decorate([
|
|
494
|
-
mobx_1.action.bound
|
|
495
|
-
], RootStore.prototype, "setSocket", null);
|
|
496
|
-
__decorate([
|
|
497
|
-
mobx_1.action.bound
|
|
498
|
-
], RootStore.prototype, "setSelectedMessage", null);
|
|
499
|
-
__decorate([
|
|
500
|
-
mobx_1.computed
|
|
501
|
-
], RootStore.prototype, "isConversationStarted", null);
|
|
502
|
-
__decorate([
|
|
503
|
-
mobx_1.computed
|
|
504
|
-
], RootStore.prototype, "botName", null);
|
|
505
|
-
__decorate([
|
|
506
|
-
mobx_1.computed
|
|
507
|
-
], RootStore.prototype, "hasBotInfoDescription", null);
|
|
508
|
-
__decorate([
|
|
509
|
-
mobx_1.computed
|
|
510
|
-
], RootStore.prototype, "botAvatarUrl", null);
|
|
511
|
-
__decorate([
|
|
512
|
-
mobx_1.computed
|
|
513
|
-
], RootStore.prototype, "rtl", null);
|
|
514
|
-
__decorate([
|
|
515
|
-
mobx_1.computed
|
|
516
|
-
], RootStore.prototype, "escapeHTML", null);
|
|
517
|
-
__decorate([
|
|
518
|
-
mobx_1.computed
|
|
519
|
-
], RootStore.prototype, "currentMessages", null);
|
|
520
|
-
__decorate([
|
|
521
|
-
mobx_1.computed
|
|
522
|
-
], RootStore.prototype, "currentConversationId", null);
|
|
523
|
-
__decorate([
|
|
524
|
-
mobx_1.action.bound
|
|
525
|
-
], RootStore.prototype, "updateMessages", null);
|
|
526
|
-
__decorate([
|
|
527
|
-
mobx_1.action.bound
|
|
528
|
-
], RootStore.prototype, "updateLastMessage", null);
|
|
529
|
-
__decorate([
|
|
530
|
-
mobx_1.action.bound
|
|
531
|
-
], RootStore.prototype, "clearMessages", null);
|
|
532
|
-
__decorate([
|
|
533
|
-
mobx_1.action.bound
|
|
534
|
-
], RootStore.prototype, "deleteConversation", null);
|
|
535
|
-
__decorate([
|
|
536
|
-
mobx_1.action.bound
|
|
537
|
-
], RootStore.prototype, "addEventToConversation", null);
|
|
538
|
-
__decorate([
|
|
539
|
-
mobx_1.action.bound
|
|
540
|
-
], RootStore.prototype, "updateTyping", null);
|
|
541
|
-
__decorate([
|
|
542
|
-
mobx_1.action.bound
|
|
543
|
-
], RootStore.prototype, "initializeChat", null);
|
|
544
|
-
__decorate([
|
|
545
|
-
mobx_1.action.bound
|
|
546
|
-
], RootStore.prototype, "fetchBotInfo", null);
|
|
547
|
-
__decorate([
|
|
548
|
-
mobx_1.action.bound
|
|
549
|
-
], RootStore.prototype, "fetchLanguage", null);
|
|
550
|
-
__decorate([
|
|
551
|
-
mobx_1.action.bound
|
|
552
|
-
], RootStore.prototype, "fetchConversations", null);
|
|
553
|
-
__decorate([
|
|
554
|
-
mobx_1.action.bound
|
|
555
|
-
], RootStore.prototype, "fetchConversation", null);
|
|
556
|
-
__decorate([
|
|
557
|
-
mobx_1.action.bound
|
|
558
|
-
], RootStore.prototype, "sendMessage", null);
|
|
559
|
-
__decorate([
|
|
560
|
-
mobx_1.action.bound
|
|
561
|
-
], RootStore.prototype, "startConversation", null);
|
|
562
|
-
__decorate([
|
|
563
|
-
mobx_1.action.bound
|
|
564
|
-
], RootStore.prototype, "createConversation", null);
|
|
565
|
-
__decorate([
|
|
566
|
-
mobx_1.action.bound
|
|
567
|
-
], RootStore.prototype, "resetConversation", null);
|
|
568
|
-
__decorate([
|
|
569
|
-
mobx_1.action.bound
|
|
570
|
-
], RootStore.prototype, "extractFeedback", null);
|
|
571
|
-
__decorate([
|
|
572
|
-
mobx_1.action.bound
|
|
573
|
-
], RootStore.prototype, "sendFeedback", null);
|
|
574
|
-
__decorate([
|
|
575
|
-
mobx_1.action.bound
|
|
576
|
-
], RootStore.prototype, "downloadConversation", null);
|
|
577
|
-
__decorate([
|
|
578
|
-
mobx_1.action.bound
|
|
579
|
-
], RootStore.prototype, "sendData", null);
|
|
580
|
-
__decorate([
|
|
581
|
-
mobx_1.action.bound
|
|
582
|
-
], RootStore.prototype, "sendVoiceMessage", null);
|
|
583
|
-
__decorate([
|
|
584
|
-
mobx_1.action.bound
|
|
585
|
-
], RootStore.prototype, "mergeConfig", null);
|
|
586
|
-
__decorate([
|
|
587
|
-
mobx_1.action.bound
|
|
588
|
-
], RootStore.prototype, "updateConfig", null);
|
|
589
|
-
__decorate([
|
|
590
|
-
mobx_1.action.bound
|
|
591
|
-
], RootStore.prototype, "updatePreferredLanguage", null);
|
|
592
|
-
__decorate([
|
|
593
|
-
mobx_1.action.bound
|
|
594
|
-
], RootStore.prototype, "_startTypingTimer", null);
|
|
595
|
-
__decorate([
|
|
596
|
-
mobx_1.action.bound
|
|
597
|
-
], RootStore.prototype, "_expireTyping", null);
|
|
598
|
-
__decorate([
|
|
599
|
-
mobx_1.action.bound
|
|
600
|
-
], RootStore.prototype, "updateBotUILanguage", null);
|
|
601
|
-
__decorate([
|
|
602
|
-
mobx_1.action.bound
|
|
603
|
-
], RootStore.prototype, "emptyDelayedMessagesQueue", null);
|
|
604
|
-
exports.RootStore = RootStore;
|
package/dist/store/view.d.ts
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { ChatDimensions, CustomAction, CustomButton } from '../typings';
|
|
2
|
-
import { RootStore } from '.';
|
|
3
|
-
declare class ViewStore {
|
|
4
|
-
private rootStore;
|
|
5
|
-
/** If false, probably embedded on a website or on the studio */
|
|
6
|
-
isFullscreen: boolean;
|
|
7
|
-
unreadCount: number;
|
|
8
|
-
dimensions: ChatDimensions;
|
|
9
|
-
isConversationsDisplayed: boolean;
|
|
10
|
-
activeView: string;
|
|
11
|
-
private transitions;
|
|
12
|
-
private _isLoading;
|
|
13
|
-
private _showBotInfo;
|
|
14
|
-
isPoweredByDisplayed: boolean;
|
|
15
|
-
focusedArea: import("mobx").IObservableValue<string>;
|
|
16
|
-
/** These buttons are displayed in the header, and can point to actions on your custom components */
|
|
17
|
-
customButtons: CustomButton[];
|
|
18
|
-
customActions: CustomAction[];
|
|
19
|
-
disableAnimations: boolean;
|
|
20
|
-
constructor(rootStore: RootStore, fullscreen: boolean);
|
|
21
|
-
get showConversationsButton(): boolean | undefined;
|
|
22
|
-
get showBotInfoButton(): boolean;
|
|
23
|
-
get showDownloadButton(): boolean | undefined;
|
|
24
|
-
get showDeleteConversationButton(): boolean | undefined;
|
|
25
|
-
get showCloseButton(): boolean;
|
|
26
|
-
get showWidgetButton(): boolean;
|
|
27
|
-
get hasUnreadMessages(): boolean;
|
|
28
|
-
get isWebchatReady(): string | false;
|
|
29
|
-
get isBotInfoDisplayed(): boolean;
|
|
30
|
-
/** Returns the active transition for the side panel, like fade in or out */
|
|
31
|
-
get sideTransition(): any;
|
|
32
|
-
get widgetTransition(): any;
|
|
33
|
-
get displayWidgetView(): boolean;
|
|
34
|
-
/** Sets the current focus to that element */
|
|
35
|
-
setFocus(element: string): void;
|
|
36
|
-
focusPrevious(): void;
|
|
37
|
-
focusNext(): void;
|
|
38
|
-
incrementUnread(): void;
|
|
39
|
-
resetUnread(): void;
|
|
40
|
-
toggleBotInfo(): void;
|
|
41
|
-
showBotInfo(): void;
|
|
42
|
-
toggleConversations(): void;
|
|
43
|
-
hideConversations(): void;
|
|
44
|
-
setLoadingCompleted(): void;
|
|
45
|
-
showPoweredBy(): void;
|
|
46
|
-
hidePoweredBy(): void;
|
|
47
|
-
setLayoutWidth(width: string | number): void;
|
|
48
|
-
setContainerWidth(width: string | number): void;
|
|
49
|
-
addCustomAction(newAction: CustomAction): void;
|
|
50
|
-
removeCustomAction(actionId: string): void;
|
|
51
|
-
addHeaderButton(newButton: CustomButton): void;
|
|
52
|
-
/** Updates one or multiple properties of a specific button */
|
|
53
|
-
updateHeaderButton(buttonId: string, newProps: Partial<CustomButton>): void;
|
|
54
|
-
removeHeaderButton(buttonId: string): void;
|
|
55
|
-
showChat(): void;
|
|
56
|
-
hideChat(): void;
|
|
57
|
-
private _endAnimation;
|
|
58
|
-
private _updateTransitions;
|
|
59
|
-
private _getFocusOrder;
|
|
60
|
-
}
|
|
61
|
-
export default ViewStore;
|