@botpress/webchat 0.5.0 → 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.
Files changed (295) hide show
  1. package/dist/App.d.ts +10 -0
  2. package/dist/Utils/colors.d.ts +18 -0
  3. package/dist/Utils/eventEmitter.d.ts +12 -0
  4. package/dist/Utils/index.d.ts +2 -0
  5. package/dist/client/MessagingClient.d.ts +27 -0
  6. package/dist/client/adapters/Audio.d.ts +19 -0
  7. package/dist/client/adapters/Card.d.ts +188 -0
  8. package/dist/client/adapters/Carousel.d.ts +147 -0
  9. package/dist/client/adapters/Choice.d.ts +45 -0
  10. package/dist/client/adapters/Dropdown.d.ts +46 -0
  11. package/dist/client/adapters/File.d.ts +19 -0
  12. package/dist/client/adapters/Image.d.ts +19 -0
  13. package/dist/client/adapters/Location.d.ts +27 -0
  14. package/dist/client/adapters/Message.d.ts +433 -0
  15. package/dist/client/adapters/Text.d.ts +20 -0
  16. package/dist/client/adapters/Utils.d.ts +5 -0
  17. package/dist/client/adapters/Video.d.ts +19 -0
  18. package/dist/client/adapters/Voice.d.ts +15 -0
  19. package/dist/client/adapters/index.d.ts +12 -0
  20. package/dist/client/index.d.ts +2 -0
  21. package/dist/components/Avatar.d.ts +6 -0
  22. package/dist/components/Block.d.ts +4 -0
  23. package/dist/components/Composer.d.ts +12 -14
  24. package/dist/components/Container.d.ts +2 -12
  25. package/dist/components/Header.d.ts +36 -26
  26. package/dist/components/LoadingIndicator.d.ts +2 -0
  27. package/dist/components/Message.d.ts +7 -0
  28. package/dist/components/MessageList.d.ts +2 -0
  29. package/dist/components/Modal.d.ts +17 -0
  30. package/dist/components/RestartConversation.d.ts +5 -0
  31. package/dist/components/Webchat.d.ts +6 -0
  32. package/dist/components/dev-tools/DevTools.d.ts +1 -0
  33. package/dist/components/dev-tools/configuration.d.ts +2 -0
  34. package/dist/components/dev-tools/helpers.d.ts +5 -0
  35. package/dist/components/index.d.ts +12 -0
  36. package/dist/components/renderers/Audio.d.ts +3 -0
  37. package/dist/components/renderers/Bubble.d.ts +5 -0
  38. package/dist/components/renderers/Button.d.ts +4 -0
  39. package/dist/components/renderers/Carousel.d.ts +3 -0
  40. package/dist/components/renderers/Column.d.ts +5 -0
  41. package/dist/components/renderers/Dropdown.d.ts +5 -0
  42. package/dist/components/renderers/File.d.ts +3 -0
  43. package/dist/components/renderers/Image.d.ts +3 -0
  44. package/dist/components/renderers/Location.d.ts +3 -0
  45. package/dist/components/renderers/Row.d.ts +5 -0
  46. package/dist/components/renderers/Text.d.ts +4 -0
  47. package/dist/components/renderers/Video.d.ts +3 -0
  48. package/dist/components/renderers/index.d.ts +2 -0
  49. package/dist/contexts/ComposerContext.d.ts +8 -0
  50. package/dist/contexts/MessageContext.d.ts +8 -0
  51. package/dist/contexts/ModalContext.d.ts +14 -0
  52. package/dist/contexts/WebchatContext.d.ts +56 -0
  53. package/dist/contexts/index.d.ts +4 -0
  54. package/dist/hooks/index.d.ts +3 -0
  55. package/dist/hooks/useImageSize.d.ts +2 -0
  56. package/dist/hooks/useRefresh.d.ts +10 -0
  57. package/dist/hooks/useWebchatStore.d.ts +30 -0
  58. package/dist/index.d.ts +3 -17
  59. package/dist/index.js +43569 -48
  60. package/dist/index.umd.cjs +702 -0
  61. package/dist/main.d.ts +11 -13
  62. package/dist/providers/ModalProvider.d.ts +8 -0
  63. package/dist/providers/WebchatProvider.d.ts +13 -0
  64. package/dist/providers/index.d.ts +2 -0
  65. package/dist/schemas/index.d.ts +1 -0
  66. package/dist/schemas/theme.d.ts +3371 -0
  67. package/dist/services/clipboard.d.ts +1 -0
  68. package/dist/services/images.d.ts +2 -0
  69. package/dist/services/index.d.ts +3 -0
  70. package/dist/services/toast.d.ts +17 -0
  71. package/dist/themes/dawn.d.ts +2 -0
  72. package/dist/themes/duskTheme.d.ts +2 -0
  73. package/dist/themes/eggplant.d.ts +2 -0
  74. package/dist/themes/galaxy.d.ts +2 -0
  75. package/dist/themes/index.d.ts +6 -0
  76. package/dist/themes/midnight.d.ts +2 -0
  77. package/dist/themes/prism.d.ts +2 -0
  78. package/dist/twind.config.d.ts +9 -0
  79. package/dist/types/block-type.d.ts +93 -0
  80. package/dist/types/image.d.ts +11 -0
  81. package/dist/types/index.d.ts +2 -0
  82. package/dist/vite.svg +1 -0
  83. package/index.html +18 -0
  84. package/package.json +60 -48
  85. package/public/vite.svg +1 -0
  86. package/src/App.tsx +41 -0
  87. package/src/Utils/colors.ts +45 -0
  88. package/src/Utils/eventEmitter.ts +31 -0
  89. package/src/Utils/index.ts +2 -0
  90. package/src/assets/check-circle-bold.svg +5 -0
  91. package/src/assets/chevron-up.svg +3 -0
  92. package/src/assets/file-05.svg +6 -0
  93. package/src/assets/globe-02.svg +6 -0
  94. package/src/assets/help-circle.svg +3 -0
  95. package/src/assets/info-circle.svg +3 -0
  96. package/src/assets/lock-01.svg +4 -0
  97. package/src/assets/mail-01.svg +6 -0
  98. package/src/assets/minus-circle.svg +3 -0
  99. package/src/assets/phone.svg +6 -0
  100. package/src/assets/send-03.svg +4 -0
  101. package/src/assets/share-04.svg +5 -0
  102. package/src/assets/slash-circle-01.svg +3 -0
  103. package/src/assets/x-circle-bold.svg +5 -0
  104. package/src/assets/x-close.svg +3 -0
  105. package/src/assets/x.svg +3 -0
  106. package/src/client/MessagingClient.ts +87 -0
  107. package/src/client/adapters/Audio.ts +10 -0
  108. package/src/client/adapters/Card.ts +104 -0
  109. package/src/client/adapters/Carousel.ts +11 -0
  110. package/src/client/adapters/Choice.ts +48 -0
  111. package/src/client/adapters/Dropdown.ts +39 -0
  112. package/src/client/adapters/File.ts +10 -0
  113. package/src/client/adapters/Image.ts +10 -0
  114. package/src/client/adapters/Location.ts +18 -0
  115. package/src/client/adapters/Message.ts +26 -0
  116. package/src/client/adapters/Text.ts +11 -0
  117. package/src/client/adapters/Utils.ts +11 -0
  118. package/src/client/adapters/Video.ts +10 -0
  119. package/src/client/adapters/Voice.ts +9 -0
  120. package/src/client/adapters/index.ts +12 -0
  121. package/src/client/index.ts +2 -0
  122. package/src/components/Avatar.tsx +22 -0
  123. package/src/components/Block.tsx +17 -0
  124. package/src/components/Composer.tsx +115 -0
  125. package/src/components/Container.tsx +17 -0
  126. package/src/components/Header.tsx +141 -0
  127. package/src/components/LoadingIndicator.tsx +15 -0
  128. package/src/components/Message.tsx +52 -0
  129. package/src/components/MessageList.tsx +75 -0
  130. package/src/components/Modal.tsx +49 -0
  131. package/src/components/RestartConversation.tsx +52 -0
  132. package/src/components/Webchat.tsx +68 -0
  133. package/src/components/dev-tools/DevTools.tsx +496 -0
  134. package/src/components/dev-tools/configuration.tsx +27 -0
  135. package/src/components/dev-tools/helpers.ts +21 -0
  136. package/src/components/index.ts +12 -0
  137. package/src/components/renderers/Audio.tsx +11 -0
  138. package/src/components/renderers/Bubble.tsx +12 -0
  139. package/src/components/renderers/Button.tsx +59 -0
  140. package/src/components/renderers/Carousel.tsx +51 -0
  141. package/src/components/renderers/Column.tsx +22 -0
  142. package/src/components/renderers/Dropdown.tsx +170 -0
  143. package/src/components/renderers/File.tsx +13 -0
  144. package/src/components/renderers/Image.tsx +63 -0
  145. package/src/components/renderers/Location.tsx +16 -0
  146. package/src/components/renderers/Row.tsx +22 -0
  147. package/src/components/renderers/Text.tsx +32 -0
  148. package/src/components/renderers/Video.tsx +11 -0
  149. package/src/components/renderers/index.ts +28 -0
  150. package/src/contexts/ComposerContext.ts +16 -0
  151. package/src/contexts/MessageContext.ts +16 -0
  152. package/src/contexts/ModalContext.ts +19 -0
  153. package/src/contexts/WebchatContext.ts +61 -0
  154. package/src/contexts/index.ts +4 -0
  155. package/src/hooks/index.ts +3 -0
  156. package/src/hooks/useImageSize.ts +30 -0
  157. package/src/hooks/useRefresh.ts +33 -0
  158. package/src/hooks/useWebchatStore.ts +45 -0
  159. package/src/index.css +18 -0
  160. package/src/index.ts +3 -0
  161. package/src/main.tsx +33 -0
  162. package/src/providers/ModalProvider.tsx +35 -0
  163. package/src/providers/WebchatProvider.tsx +107 -0
  164. package/src/providers/index.ts +2 -0
  165. package/src/schemas/index.ts +1 -0
  166. package/src/schemas/theme.ts +188 -0
  167. package/src/services/clipboard.ts +8 -0
  168. package/src/services/images.ts +39 -0
  169. package/src/services/index.ts +3 -0
  170. package/src/services/toast.tsx +71 -0
  171. package/src/themes/dawn.ts +277 -0
  172. package/src/themes/duskTheme.ts +349 -0
  173. package/src/themes/eggplant.ts +353 -0
  174. package/src/themes/galaxy.ts +323 -0
  175. package/src/themes/index.ts +6 -0
  176. package/src/themes/midnight.ts +276 -0
  177. package/src/themes/prism.ts +349 -0
  178. package/src/twind.config.ts +31 -0
  179. package/src/types/block-type.ts +150 -0
  180. package/src/types/image.ts +10 -0
  181. package/src/types/index.ts +2 -0
  182. package/src/vite-env.d.ts +1 -0
  183. package/tailwind.config.js +0 -0
  184. package/tsconfig.json +30 -0
  185. package/tsconfig.node.json +10 -0
  186. package/vite.config.ts +31 -0
  187. package/README.md +0 -31
  188. package/assets/fonts/roboto/roboto.woff2 +0 -0
  189. package/assets/fonts/roboto/roboto500.woff2 +0 -0
  190. package/assets/fonts/roboto.css +0 -128
  191. package/assets/notification.mp3 +0 -0
  192. package/dist/components/Composer.js +0 -118
  193. package/dist/components/Container.js +0 -62
  194. package/dist/components/ConversationList.d.ts +0 -10
  195. package/dist/components/ConversationList.js +0 -41
  196. package/dist/components/Footer.d.ts +0 -3
  197. package/dist/components/Footer.js +0 -21
  198. package/dist/components/Header.js +0 -181
  199. package/dist/components/VoiceRecorder.d.ts +0 -10
  200. package/dist/components/VoiceRecorder.js +0 -137
  201. package/dist/components/common/Avatar/index.d.ts +0 -9
  202. package/dist/components/common/Avatar/index.js +0 -13
  203. package/dist/components/common/BotInfo/index.d.ts +0 -10
  204. package/dist/components/common/BotInfo/index.js +0 -102
  205. package/dist/components/common/BotInfo/style.scss +0 -88
  206. package/dist/components/common/ConfirmDialog/index.d.ts +0 -11
  207. package/dist/components/common/ConfirmDialog/index.js +0 -78
  208. package/dist/components/common/ConfirmDialog/style.module.scss +0 -48
  209. package/dist/components/common/Dialog/index.d.ts +0 -17
  210. package/dist/components/common/Dialog/index.js +0 -57
  211. package/dist/components/common/Dialog/style.module.scss +0 -29
  212. package/dist/components/common/ToolTip/index.d.ts +0 -10
  213. package/dist/components/common/ToolTip/index.js +0 -163
  214. package/dist/components/common/ToolTip/style.module.scss +0 -108
  215. package/dist/components/common/ToolTip/utils.d.ts +0 -15
  216. package/dist/components/common/ToolTip/utils.js +0 -78
  217. package/dist/components/common/variables.scss +0 -38
  218. package/dist/components/messages/InlineFeedback.d.ts +0 -11
  219. package/dist/components/messages/InlineFeedback.js +0 -56
  220. package/dist/components/messages/Message.d.ts +0 -11
  221. package/dist/components/messages/Message.js +0 -106
  222. package/dist/components/messages/MessageGroup.d.ts +0 -23
  223. package/dist/components/messages/MessageGroup.js +0 -63
  224. package/dist/components/messages/MessageList.d.ts +0 -10
  225. package/dist/components/messages/MessageList.js +0 -154
  226. package/dist/core/api.d.ts +0 -23
  227. package/dist/core/api.js +0 -117
  228. package/dist/core/constants.d.ts +0 -14
  229. package/dist/core/constants.js +0 -29
  230. package/dist/core/socket.d.ts +0 -14
  231. package/dist/core/socket.js +0 -57
  232. package/dist/declaration.d.ts +0 -1
  233. package/dist/declaration.js +0 -1
  234. package/dist/fonts/roboto.d.ts +0 -4
  235. package/dist/fonts/roboto.js +0 -9
  236. package/dist/globals.d.ts +0 -7
  237. package/dist/globals.js +0 -2
  238. package/dist/icons/Add.d.ts +0 -6
  239. package/dist/icons/Add.js +0 -10
  240. package/dist/icons/Cancel.d.ts +0 -5
  241. package/dist/icons/Cancel.js +0 -10
  242. package/dist/icons/Chat.d.ts +0 -6
  243. package/dist/icons/Chat.js +0 -9
  244. package/dist/icons/Close.d.ts +0 -3
  245. package/dist/icons/Close.js +0 -10
  246. package/dist/icons/Delete.d.ts +0 -3
  247. package/dist/icons/Delete.js +0 -11
  248. package/dist/icons/Download.d.ts +0 -3
  249. package/dist/icons/Download.js +0 -10
  250. package/dist/icons/Email.d.ts +0 -3
  251. package/dist/icons/Email.js +0 -8
  252. package/dist/icons/Information.d.ts +0 -3
  253. package/dist/icons/Information.js +0 -12
  254. package/dist/icons/List.d.ts +0 -3
  255. package/dist/icons/List.js +0 -15
  256. package/dist/icons/Microphone.d.ts +0 -5
  257. package/dist/icons/Microphone.js +0 -12
  258. package/dist/icons/Phone.d.ts +0 -3
  259. package/dist/icons/Phone.js +0 -8
  260. package/dist/icons/Reload.d.ts +0 -3
  261. package/dist/icons/Reload.js +0 -10
  262. package/dist/icons/ThumbsDown.d.ts +0 -3
  263. package/dist/icons/ThumbsDown.js +0 -11
  264. package/dist/icons/ThumbsUp.d.ts +0 -3
  265. package/dist/icons/ThumbsUp.js +0 -11
  266. package/dist/icons/Website.d.ts +0 -3
  267. package/dist/icons/Website.js +0 -8
  268. package/dist/main.js +0 -336
  269. package/dist/store/composer.d.ts +0 -17
  270. package/dist/store/composer.js +0 -98
  271. package/dist/store/index.d.ts +0 -82
  272. package/dist/store/index.js +0 -576
  273. package/dist/store/view.d.ts +0 -61
  274. package/dist/store/view.js +0 -361
  275. package/dist/translations/ar.json +0 -30
  276. package/dist/translations/de.json +0 -32
  277. package/dist/translations/en.json +0 -40
  278. package/dist/translations/es.json +0 -19
  279. package/dist/translations/fr.json +0 -40
  280. package/dist/translations/index.d.ts +0 -9
  281. package/dist/translations/index.js +0 -95
  282. package/dist/translations/it.json +0 -38
  283. package/dist/translations/pt.json +0 -19
  284. package/dist/translations/ru.json +0 -24
  285. package/dist/translations/uk.json +0 -24
  286. package/dist/typings.d.ts +0 -378
  287. package/dist/typings.js +0 -2
  288. package/dist/utils/analytics.d.ts +0 -5
  289. package/dist/utils/analytics.js +0 -37
  290. package/dist/utils/index.d.ts +0 -3
  291. package/dist/utils/index.js +0 -27
  292. package/dist/utils/storage.d.ts +0 -16
  293. package/dist/utils/storage.js +0 -129
  294. package/dist/utils/webchatEvents.d.ts +0 -2
  295. package/dist/utils/webchatEvents.js +0 -14
@@ -1,19 +0,0 @@
1
- {
2
- "composer.placeholder": "Fale com {name}",
3
- "composer.placeholderInit": "Diga alguma coisa para {name}",
4
- "composer.send": "Mandar",
5
- "header.conversations": "Conversas",
6
- "header.deleteConversation": "Tem certeza de que deseja excluir toda esta conversa?",
7
- "header.deleteConversationYes": "Excluir",
8
- "header.deleteConversationNo": "Cancelar",
9
- "conversationList.untitledConversation": "Conversa sem título",
10
- "conversationList.title": "Conversa {id}",
11
- "botInfo.backToConversation": "De volta à conversa",
12
- "botInfo.startConversation": "Iniciar conversa",
13
- "botInfo.privacyPolicy": "Ver política de privacidade",
14
- "botInfo.termsAndConditions": "Ver termos de serviço",
15
- "botInfo.preferredLanguage": "Preferred Language",
16
- "store.resetSessionMessage": "Redefinir a conversa",
17
- "messages.newMessage": "Nova mensagem",
18
- "messages.newMessages": "Novas mensagens"
19
- }
@@ -1,24 +0,0 @@
1
- {
2
- "composer.placeholder": "Ответить {name}",
3
- "composer.placeholderInit": "Скажи что-нибудь {name}",
4
- "composer.send": "Отправить",
5
- "header.conversations": "Разговоры",
6
- "header.deleteConversation": "Вы уверены, что хотите удалить всю беседу?",
7
- "header.deleteConversationYes": "удалять",
8
- "header.deleteConversationNo": "отменить",
9
- "conversationList.untitledConversation": "Разговор без названия",
10
- "conversationList.title": "Разговор {id}",
11
- "botInfo.backToConversation": "Назад к разговору",
12
- "botInfo.startConversation": "Начать разговор",
13
- "botInfo.privacyPolicy": "Показать Политику конфиденцеальности",
14
- "botInfo.termsAndConditions": "Показать Условия использования",
15
- "botInfo.preferredLanguage": "Предпочитаемый язык",
16
- "store.resetSessionMessage": "Начать разговор заново",
17
- "loginForm.userName": "Логин",
18
- "loginForm.password": "Пароль",
19
- "loginForm.submit": "Отправить",
20
- "loginForm.formTitle": "Форма для входа",
21
- "loginForm.providedCredentials": "Введенные данные",
22
- "messages.newMessage": "Новое сообщение",
23
- "messages.newMessages": "новые сообщения"
24
- }
@@ -1,24 +0,0 @@
1
- {
2
- "composer.placeholder": "Відповісти {name}",
3
- "composer.placeholderInit": "Скажи щось {name}",
4
- "composer.send": "Надіслати",
5
- "header.conversations": "Розмови",
6
- "header.deleteConversation": "Ви впевнені, що хочете видалити всю цю розмову?",
7
- "header.deleteConversationYes": "Видалити",
8
- "header.deleteConversationNo": "Скасувати",
9
- "conversationList.untitledConversation": "Розмова без назви",
10
- "conversationList.title": "Розмова {id}",
11
- "botInfo.backToConversation": "Повернутись до розмови",
12
- "botInfo.startConversation": "Розпочати розмову",
13
- "botInfo.privacyPolicy": "Показати Політику конфіденційності",
14
- "botInfo.termsAndConditions": "Показати Умови користування",
15
- "botInfo.preferredLanguage": "Бажана мова",
16
- "store.resetSessionMessage": "Розпочати розмову заново",
17
- "loginForm.userName": "Логін",
18
- "loginForm.password": "Пароль",
19
- "loginForm.submit": "Надіслати",
20
- "loginForm.formTitle": "Форма для входу",
21
- "loginForm.providedCredentials": "Введені дані",
22
- "messages.newMessage": "Нове повідомлення",
23
- "messages.newMessages": "нові повідомлення"
24
- }
package/dist/typings.d.ts DELETED
@@ -1,378 +0,0 @@
1
- /// <reference types="react" />
2
- import { UserCredentials } from '@botpress/messaging-socket';
3
- import { RootStore } from './store';
4
- import { BPStorage } from './utils/storage';
5
- declare global {
6
- interface Window {
7
- __BP_VISITOR_SOCKET_ID: string;
8
- __BP_VISITOR_ID: string;
9
- botpressWebChat: any;
10
- store: RootStore;
11
- BOT_ID: string;
12
- SEND_USAGE_STATS: boolean;
13
- USE_SESSION_STORAGE: boolean;
14
- BP_STORAGE: BPStorage;
15
- botpress: {
16
- [moduleName: string]: any;
17
- };
18
- }
19
- }
20
- export declare namespace Renderer {
21
- interface Message {
22
- type?: string;
23
- className?: string;
24
- payload?: any;
25
- store?: RootStore;
26
- bp?: StudioConnector;
27
- fromLabel?: string;
28
- messageId?: uuid;
29
- /** When true, the message isn't wrapped by its bubble */
30
- noBubble?: boolean;
31
- keyboard?: any;
32
- eventId?: string;
33
- isLastGroup?: boolean;
34
- isLastOfGroup?: boolean;
35
- isBotMessage?: boolean;
36
- isLastMessage?: boolean;
37
- sentOn?: Date;
38
- inlineFeedback?: any;
39
- onSendData?: (data: any) => Promise<Message | void>;
40
- onFileUpload?: (label: string, payload: any, file: File) => Promise<void>;
41
- /** Allows to autoplay voice messages coming from the bot */
42
- onAudioEnded?: () => void;
43
- shouldPlay?: boolean;
44
- }
45
- type Button = {
46
- label: string;
47
- payload: any;
48
- preventDoubleClick: boolean;
49
- onButtonClick: (title: any, payload: any) => void;
50
- } & Pick<Message, 'onFileUpload'>;
51
- type Text = {
52
- text: string;
53
- markdown: boolean;
54
- escapeHTML: boolean;
55
- intl?: any;
56
- maxLength?: number;
57
- } & Message;
58
- interface Option {
59
- label: string;
60
- value: string;
61
- }
62
- type Dropdown = {
63
- options: Option[];
64
- buttonText?: string;
65
- escapeHTML: boolean;
66
- allowCreation?: boolean;
67
- placeholderText?: string;
68
- allowMultiple?: boolean;
69
- width?: number;
70
- markdown: boolean;
71
- message: string;
72
- displayInKeyboard?: boolean;
73
- } & Message;
74
- type QuickReply = {
75
- buttons: any;
76
- quick_replies: any;
77
- disableFreeText: boolean;
78
- } & Message;
79
- type QuickReplyButton = {
80
- allowMultipleClick: boolean;
81
- title: string;
82
- } & Button;
83
- interface FileMessage {
84
- file: {
85
- url: string;
86
- title: string;
87
- storage: string;
88
- text: string;
89
- };
90
- escapeTextHTML: boolean;
91
- }
92
- interface VoiceMessage {
93
- file: {
94
- type: string;
95
- audio: string;
96
- autoPlay?: boolean;
97
- };
98
- shouldPlay: boolean;
99
- onAudioEnded: () => void;
100
- }
101
- interface FileInput {
102
- onFileChanged: (event: HTMLInputEvent) => void;
103
- name: string;
104
- className: string;
105
- accept: string;
106
- placeholder: string;
107
- disabled?: boolean;
108
- }
109
- interface Carousel {
110
- elements: Card[];
111
- settings: any;
112
- }
113
- interface Card {
114
- picture: string;
115
- title: string;
116
- subtitle: string;
117
- buttons: CardButton[];
118
- }
119
- interface CardButton {
120
- url: string;
121
- title: string;
122
- type: string;
123
- payload: any;
124
- text: string;
125
- }
126
- }
127
- export declare namespace View {
128
- type MenuAnimations = 'fadeIn' | 'fadeOut' | undefined;
129
- }
130
- /** These are the functions exposed by the studio to the modules */
131
- export interface StudioConnector {
132
- /** Event emitter */
133
- events: any;
134
- /** An axios instance */
135
- axios: any;
136
- getModuleInjector: any;
137
- loadModuleView: any;
138
- }
139
- export declare type WebchatEventType = 'LIFECYCLE.LOADED' | 'LIFECYCLE.READY' | 'UI.OPENED' | 'UI.CLOSED' | 'UI.RESIZE' | 'UI.SET-CLASS' | 'CONFIG.SET' | 'MESSAGE.SENT' | 'MESSAGE.RECEIVED' | 'MESSAGE.SELECTED' | 'USER.CONNECTED';
140
- export interface WebchatEvent {
141
- type: WebchatEventType;
142
- value: any;
143
- chatId: string;
144
- }
145
- export interface Config {
146
- /** Url of the messaging server */
147
- messagingUrl: string;
148
- /** Id of your messaging client */
149
- clientId: string;
150
- /**
151
- * Refers to a specific webchat reference in parent window. Useful when using multiple chat window
152
- * @default 'bp-web-widget'
153
- */
154
- chatId: string;
155
- /**
156
- * Url where the webchat bundle is hosted
157
- * @default: '/'
158
- */
159
- hostUrl?: string;
160
- /**
161
- * Url of the Media File Service where we fetch the bot info
162
- * @default ''
163
- */
164
- mediaFileServiceUrl?: string;
165
- /**
166
- * Key used to encrypt data in the localStorage
167
- * @default '''
168
- */
169
- encryptionKey?: string;
170
- /**
171
- * Provide a path to a stylesheet to customize the webchat
172
- * @default '''
173
- */
174
- stylesheet?: string;
175
- /**
176
- * If false, will hide the conversation list pane
177
- * @default true
178
- */
179
- showConversationsButton?: boolean;
180
- /**
181
- * If true, will display a timestamp under each messages
182
- * @default false
183
- */
184
- showTimestamp?: boolean;
185
- /**
186
- * Allows the user to download the conversation history
187
- * @default true
188
- */
189
- enableTranscriptDownload?: boolean;
190
- /**
191
- * Allows the user to delete its conversation history
192
- * @default false
193
- */
194
- enableConversationDeletion?: boolean;
195
- /**
196
- * Close the webchat when pressing the Esc key
197
- * @default true
198
- */
199
- closeOnEscape?: boolean;
200
- /**
201
- * Displays the bot name to the right of its avatar
202
- * @default ''
203
- */
204
- botName?: string;
205
- /**
206
- * Allows to set a custom composer placeholder
207
- * @default 'Reply to {name}'
208
- */
209
- composerPlaceholder?: string;
210
- /**
211
- * Allow to specify a custom URL for the bot's avatar
212
- * @default '''
213
- */
214
- avatarUrl?: string;
215
- /** Force the display language of the webchat (en, fr, ar, ru, etc..)
216
- * Defaults to the user's browser language if not set
217
- * Set to 'browser' to force use the browser's language
218
- * @default 'browser'
219
- */
220
- locale?: 'browser' | string;
221
- /**
222
- * Small description written under the bot's name
223
- * @default ''
224
- */
225
- botConversationDescription?: string;
226
- /**
227
- * When true, the widget button to open the chat is hidden
228
- * @default false
229
- */
230
- hideWidget?: boolean;
231
- /**
232
- * Disable the slide in / out animations of the webchat
233
- * @default false
234
- */
235
- disableAnimations?: boolean;
236
- /**
237
- * When true, webchat displays a voice icon in the composer to send voice messages (must use Google Speech integration)
238
- * @default false
239
- */
240
- enableVoiceComposer?: boolean;
241
- /**
242
- * Use sessionStorage instead of localStorage, which means the session expires when tab is closed
243
- * @default false
244
- */
245
- useSessionStorage?: boolean;
246
- /**
247
- * Sends an event to the parent container with the width provided
248
- * @default 360
249
- */
250
- containerWidth?: string | number;
251
- /**
252
- * Sets the width of the webchat
253
- * @default 360
254
- */
255
- layoutWidth?: string | number;
256
- /**
257
- * Show Powered By Botpress in the footer
258
- * @default false
259
- */
260
- showPoweredBy?: boolean;
261
- /**
262
- * When enabled, sent messages are persisted to local storage (recall previous messages)
263
- * @default true
264
- */
265
- enablePersistHistory?: boolean;
266
- /**
267
- * Experimental: expose the store to the parent frame for more control on the webchat's behavior
268
- * @default false
269
- */
270
- lazySocket?: boolean;
271
- /**
272
- * If true, chat will no longer play the notification sound for new messages.
273
- * @default false
274
- */
275
- disableNotificationSound?: boolean;
276
- /**
277
- * CSS class to be applied to iframe
278
- * @default ''
279
- */
280
- className?: string;
281
- /**
282
- * Google Maps API Key required to display the map.
283
- * Will display a link to Google Maps otherwise
284
- * @default ''
285
- */
286
- googleMapsAPIKey?: string;
287
- /**
288
- * Allows setting a custom user id
289
- */
290
- customUser?: UserCredentials;
291
- }
292
- export interface BotDetails {
293
- website?: string;
294
- phoneNumber?: string;
295
- termsConditions?: string;
296
- privacyPolicy?: string;
297
- emailAddress?: string;
298
- avatarUrl?: string;
299
- coverPictureUrl?: string;
300
- }
301
- export interface BotInfo {
302
- name: string;
303
- description: string;
304
- details: BotDetails;
305
- showBotInfoPage: boolean;
306
- languages: string[];
307
- security: {
308
- escapeHTML: boolean;
309
- };
310
- lazySocket: boolean;
311
- extraStylesheet?: string;
312
- disableNotificationSound?: boolean;
313
- }
314
- export declare type uuid = string;
315
- export interface Conversation {
316
- id: uuid;
317
- clientId: uuid;
318
- userId: uuid;
319
- createdOn: Date;
320
- }
321
- export interface RecentConversation extends Conversation {
322
- lastMessage?: Message;
323
- }
324
- /** Represents the current conversation with all messages */
325
- export declare type CurrentConversation = {
326
- botId: string;
327
- messages: Message[];
328
- userId: string;
329
- user_last_seen_on: Date | undefined;
330
- /** Event ? */
331
- typingUntil: any;
332
- } & Conversation;
333
- export interface Message {
334
- id: uuid;
335
- conversationId: uuid;
336
- authorId: uuid | undefined;
337
- sentOn: Date;
338
- payload: any;
339
- timeInMs?: number;
340
- }
341
- export interface QueuedMessage {
342
- message: Message;
343
- showAt: Date;
344
- }
345
- export interface HTMLInputEvent extends Event {
346
- target: HTMLInputElement & EventTarget;
347
- }
348
- export interface ChatDimensions {
349
- /**
350
- * The container is the frame around the webchat.
351
- * Setting the container bigger than the layout makes it possible to add components
352
- */
353
- container: string | number;
354
- /** The layout is the zone where the user speaks with the bot */
355
- layout: string | number;
356
- }
357
- export interface CustomButton {
358
- /** An ID to identify your button. It is required to remove it */
359
- id: string;
360
- /** This text will be displayed when the mouse is over the button */
361
- label?: string;
362
- /** Supply either a function or an element which will render the button */
363
- icon: Function | JSX.Element;
364
- /** The event triggered when the button is clicked */
365
- onClick: (buttonId: string, headerComponent: JSX.Element, event: React.MouseEvent) => void;
366
- }
367
- export interface CustomAction {
368
- /** An ID to identify your action. It is required to remove it */
369
- id: string;
370
- /** This text will be displayed in the context menu */
371
- label: string;
372
- /** The event triggered when the action is clicked */
373
- onClick: (actionId: string, messageProps: any, event: React.MouseEvent) => void;
374
- }
375
- export interface EventFeedback {
376
- messageId: uuid;
377
- feedback?: number;
378
- }
package/dist/typings.js DELETED
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,5 +0,0 @@
1
- export declare const initializeAnalytics: () => void;
2
- export declare type MessageDirection = 'sent' | 'received';
3
- export declare const trackMessage: (direction: MessageDirection) => void;
4
- export declare type WebchatState = 'show' | 'hide' | 'toggle';
5
- export declare const trackWebchatState: (state: WebchatState) => void;
@@ -1,37 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.trackWebchatState = exports.trackMessage = exports.initializeAnalytics = void 0;
7
- const react_ga_1 = __importDefault(require("react-ga"));
8
- const initializeAnalytics = () => {
9
- if (window.SEND_USAGE_STATS) {
10
- try {
11
- react_ga_1.default.initialize('UA-90044826-2');
12
- react_ga_1.default.pageview(`${window.location.pathname}${window.location.search}`);
13
- }
14
- catch (err) {
15
- console.error('Error initializing analytics', err);
16
- }
17
- }
18
- };
19
- exports.initializeAnalytics = initializeAnalytics;
20
- const trackMessage = (direction) => {
21
- if (window.SEND_USAGE_STATS) {
22
- try {
23
- react_ga_1.default.event({ category: 'Interactions', action: `message ${direction}` });
24
- }
25
- catch (_a) { }
26
- }
27
- };
28
- exports.trackMessage = trackMessage;
29
- const trackWebchatState = (state) => {
30
- if (window.SEND_USAGE_STATS) {
31
- try {
32
- react_ga_1.default.event({ category: 'Display', action: state });
33
- }
34
- catch (_a) { }
35
- }
36
- };
37
- exports.trackWebchatState = trackWebchatState;
@@ -1,3 +0,0 @@
1
- export declare const isIE: boolean;
2
- export declare const downloadFile: (name: string, blob: Blob) => void;
3
- export declare const renderUnsafeHTML: (message: string | undefined, escaped: boolean) => string;
@@ -1,27 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.renderUnsafeHTML = exports.downloadFile = exports.isIE = void 0;
7
- const snarkdown_1 = __importDefault(require("snarkdown"));
8
- exports.isIE = window.navigator.userAgent.match(/MSIE|Trident/) !== null;
9
- const downloadFile = (name, blob) => {
10
- const url = window.URL.createObjectURL(blob);
11
- const link = document.createElement('a');
12
- link.href = url;
13
- link.setAttribute('download', name);
14
- document.body.appendChild(link);
15
- link.click();
16
- document.body.removeChild(link);
17
- window.URL.revokeObjectURL(url);
18
- };
19
- exports.downloadFile = downloadFile;
20
- const renderUnsafeHTML = (message = '', escaped) => {
21
- if (escaped) {
22
- message = message.replace(/</g, '&lt;').replace(/>/g, '&gt;');
23
- }
24
- const html = (0, snarkdown_1.default)(message);
25
- return html.replace(/<a href/gi, '<a target="_blank" href');
26
- };
27
- exports.renderUnsafeHTML = renderUnsafeHTML;
@@ -1,16 +0,0 @@
1
- import { Config } from '../typings';
2
- export declare class BPStorage {
3
- private _config?;
4
- private _storage;
5
- constructor(config?: Config);
6
- get config(): Config | undefined;
7
- set config(config: Config | undefined);
8
- private serialize;
9
- private deserialize;
10
- private getStorageKey;
11
- private getDriver;
12
- set<T>(key: string, value: T): void;
13
- get<T = string>(key: string): T | undefined;
14
- del(key: string): void;
15
- }
16
- export default BPStorage;
@@ -1,129 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.BPStorage = void 0;
7
- const aes_1 = __importDefault(require("crypto-js/aes"));
8
- const enc_utf8_1 = __importDefault(require("crypto-js/enc-utf8"));
9
- const sha256_1 = __importDefault(require("crypto-js/sha256"));
10
- const js_cookie_1 = __importDefault(require("js-cookie"));
11
- class BPStorage {
12
- constructor(config) {
13
- this.serialize = (value) => {
14
- var _a, _b;
15
- if (value === null || value === undefined) {
16
- throw new Error('[Storage] Cannot store null or undefined values');
17
- }
18
- try {
19
- let str = '';
20
- if (typeof value === 'string') {
21
- str = value;
22
- }
23
- else {
24
- str = JSON.stringify(value);
25
- }
26
- if ((_b = (_a = this.config) === null || _a === void 0 ? void 0 : _a.encryptionKey) === null || _b === void 0 ? void 0 : _b.length) {
27
- str = aes_1.default.encrypt(str, this.config.encryptionKey).toString();
28
- }
29
- return str;
30
- }
31
- catch (_c) {
32
- console.error('[Storage] Error parsing value', value);
33
- return '';
34
- }
35
- };
36
- this.deserialize = (strValue) => {
37
- var _a, _b;
38
- if (strValue === null || strValue === undefined) {
39
- return undefined;
40
- }
41
- try {
42
- if ((_b = (_a = this.config) === null || _a === void 0 ? void 0 : _a.encryptionKey) === null || _b === void 0 ? void 0 : _b.length) {
43
- strValue = aes_1.default.decrypt(strValue, this.config.encryptionKey).toString(enc_utf8_1.default);
44
- }
45
- return JSON.parse(strValue);
46
- }
47
- catch (_c) {
48
- return undefined;
49
- }
50
- };
51
- this.getStorageKey = (key) => {
52
- var _a, _b, _c;
53
- const rawKey = `bp-chat-${key}`;
54
- if ((_b = (_a = this.config) === null || _a === void 0 ? void 0 : _a.encryptionKey) === null || _b === void 0 ? void 0 : _b.length) {
55
- return `${rawKey}-${(0, sha256_1.default)(`${this.config.clientId}-${this.config.encryptionKey}`).toString()}`;
56
- }
57
- else {
58
- return `${rawKey}-${(_c = this.config) === null || _c === void 0 ? void 0 : _c.clientId}`;
59
- }
60
- };
61
- this.getDriver = () => {
62
- var _a;
63
- if (this._storage) {
64
- return this._storage;
65
- }
66
- try {
67
- const storage = ((_a = this.config) === null || _a === void 0 ? void 0 : _a.useSessionStorage) === true && typeof sessionStorage !== 'undefined' ? sessionStorage : localStorage;
68
- const tempKey = '__storage_test__';
69
- storage.setItem(tempKey, tempKey);
70
- storage.removeItem(tempKey);
71
- return (this._storage = storage);
72
- }
73
- catch (e) {
74
- return (this._storage = 'cookie');
75
- }
76
- };
77
- if (config) {
78
- this._config = config;
79
- }
80
- }
81
- get config() {
82
- return this._config;
83
- }
84
- set config(config) {
85
- this._config = config;
86
- }
87
- set(key, value) {
88
- if (!this.config) {
89
- return;
90
- }
91
- try {
92
- const driver = this.getDriver();
93
- driver !== 'cookie'
94
- ? driver.setItem(this.getStorageKey(key), this.serialize(value))
95
- : js_cookie_1.default.set(this.getStorageKey(key), this.serialize(value));
96
- }
97
- catch (err) {
98
- console.error('Error while setting data into storage.', err.message);
99
- }
100
- }
101
- get(key) {
102
- if (!this.config) {
103
- return;
104
- }
105
- try {
106
- const driver = this.getDriver();
107
- return driver !== 'cookie'
108
- ? this.deserialize(driver.getItem(this.getStorageKey(key)))
109
- : this.deserialize(js_cookie_1.default.get(this.getStorageKey(key)));
110
- }
111
- catch (err) {
112
- console.error('Error while getting data from storage.', err.message);
113
- }
114
- }
115
- del(key) {
116
- if (!this.config) {
117
- return;
118
- }
119
- try {
120
- const driver = this.getDriver();
121
- driver !== 'cookie' ? driver.removeItem(this.getStorageKey(key)) : js_cookie_1.default.remove(this.getStorageKey(key));
122
- }
123
- catch (err) {
124
- console.error('Error while deleting data from storage.', err.message);
125
- }
126
- }
127
- }
128
- exports.BPStorage = BPStorage;
129
- exports.default = BPStorage;
@@ -1,2 +0,0 @@
1
- import { WebchatEventType } from '../typings';
2
- export declare const postMessageToParent: (type: WebchatEventType, value: any, chatId: string) => void;