@memori.ai/memori-react 2.12.0 → 2.13.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/CHANGELOG.md +18 -0
- package/README.md +51 -0
- package/dist/components/Chat/Chat.css +3 -3
- package/dist/components/Chat/Chat.d.ts +2 -1
- package/dist/components/Chat/Chat.js +8 -3
- package/dist/components/Chat/Chat.js.map +1 -1
- package/dist/components/ChatBubble/ChatBubble.css +10 -5
- package/dist/components/MemoriWidget/MemoriWidget.d.ts +6 -4
- package/dist/components/MemoriWidget/MemoriWidget.js +20 -17
- package/dist/components/MemoriWidget/MemoriWidget.js.map +1 -1
- package/dist/components/Typing/Typing.d.ts +7 -0
- package/dist/components/Typing/Typing.js +46 -0
- package/dist/components/Typing/Typing.js.map +1 -0
- package/dist/components/Typing/Typing.test.d.ts +1 -0
- package/dist/components/Typing/Typing.test.js +23 -0
- package/dist/components/Typing/Typing.test.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/esm/components/Chat/Chat.css +3 -3
- package/esm/components/Chat/Chat.d.ts +2 -1
- package/esm/components/Chat/Chat.js +8 -3
- package/esm/components/Chat/Chat.js.map +1 -1
- package/esm/components/ChatBubble/ChatBubble.css +10 -5
- package/esm/components/MemoriWidget/MemoriWidget.d.ts +6 -4
- package/esm/components/MemoriWidget/MemoriWidget.js +21 -18
- package/esm/components/MemoriWidget/MemoriWidget.js.map +1 -1
- package/esm/components/Typing/Typing.d.ts +7 -0
- package/esm/components/Typing/Typing.js +44 -0
- package/esm/components/Typing/Typing.js.map +1 -0
- package/esm/components/Typing/Typing.test.d.ts +1 -0
- package/esm/components/Typing/Typing.test.js +20 -0
- package/esm/components/Typing/Typing.test.js.map +1 -0
- package/esm/index.d.ts +1 -0
- package/esm/index.js +2 -2
- package/esm/index.js.map +1 -1
- package/package.json +10 -10
- package/src/components/Chat/Chat.css +3 -3
- package/src/components/Chat/Chat.tsx +20 -11
- package/src/components/Chat/__snapshots__/Chat.test.tsx.snap +14 -10
- package/src/components/ChatBubble/ChatBubble.css +10 -5
- package/src/components/MemoriWidget/MemoriWidget.tsx +34 -17
- package/src/components/Typing/Typing.stories.tsx +55 -0
- package/src/components/Typing/Typing.test.tsx +24 -0
- package/src/components/Typing/Typing.tsx +70 -0
- package/src/components/Typing/__snapshots__/Typing.test.tsx.snap +106 -0
- package/src/index.tsx +3 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
+
## [2.13.0](https://github.com/memori-ai/memori-react/compare/v2.12.0...v2.13.0) (2023-08-28)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* change typing with custom sentence, defaults with none, adds params to typeMessage ([4e18989](https://github.com/memori-ai/memori-react/commit/4e18989253421ea0c32fb617f7b9f1b90db6da18))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Maintenance
|
|
12
|
+
|
|
13
|
+
* update storybook ([3e248a0](https://github.com/memori-ai/memori-react/commit/3e248a0e1aee20d8815cf1078a201f2302428921))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Changes
|
|
17
|
+
|
|
18
|
+
* replace additionalInfo email + userID with loginToken ([b323f04](https://github.com/memori-ai/memori-react/commit/b323f04503b7fc583103b89243fb37389aed4062))
|
|
19
|
+
* typing as separate component, add text anim ([02e027e](https://github.com/memori-ai/memori-react/commit/02e027ec7f19c3d08afe3ba2c119e25fc3742e70))
|
|
20
|
+
|
|
3
21
|
## [2.12.0](https://github.com/memori-ai/memori-react/compare/v2.11.0...v2.12.0) (2023-08-21)
|
|
4
22
|
|
|
5
23
|
|
package/README.md
CHANGED
|
@@ -68,6 +68,7 @@ const App = () => (
|
|
|
68
68
|
| `height` | | `string` | "100%" | Height of the Memori |
|
|
69
69
|
| `showShare` | | `bool` | `true` | Show the share button |
|
|
70
70
|
| `showSettings` | | `bool` | `false` | Show the settings panel button |
|
|
71
|
+
| `showTypingText` | | `bool` | `false` | Show default sentences while loading text (see: Typing stories) |
|
|
71
72
|
| `showInstruct` | | `bool` | `false` | Show the switch selecting between test mode or instruct mode, needs an administrative session as a giver |
|
|
72
73
|
| `baseURL` | | `string` | | Base URL of the Memori, example: "https://app.twincreator.com" or "https://app.memorytwin.com" |
|
|
73
74
|
| `apiURL` | | `string` | "https://backend.memori.ai" | URL of the Memori API |
|
|
@@ -257,6 +258,56 @@ You can also use this to extend the default media renderer with additional media
|
|
|
257
258
|
/>
|
|
258
259
|
```
|
|
259
260
|
|
|
261
|
+
## Global utilities
|
|
262
|
+
|
|
263
|
+
When rendered, the Memori widget exposes some global functions that can be used to interact with the Memori.
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
### Get the state of the Twin
|
|
267
|
+
|
|
268
|
+
```js
|
|
269
|
+
let dialogState = getMemoriState();
|
|
270
|
+
let sessionID = getMemoriState().sessionID;
|
|
271
|
+
let dialogState = getMemoriState(myWidgetIntegrationId); // in case you have multiple widgets on the same page
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
Otherwise, you can achieve the same result manually by reading from the HTML code of the widget the attribute data-memori-engine-state.
|
|
275
|
+
|
|
276
|
+
```js
|
|
277
|
+
let dialogState = JSON.parse(
|
|
278
|
+
document.querySelector(
|
|
279
|
+
'div[data-memori-engine-state]'
|
|
280
|
+
)?.dataset?.memoriEngineState ?? '{}'
|
|
281
|
+
)
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
### Write and send a message to the Twin
|
|
285
|
+
|
|
286
|
+
Write and send a message to the Twin. You can use this method to send a message to the Twin, such as to continue a conversation with a specific message or following an action.
|
|
287
|
+
|
|
288
|
+
```js
|
|
289
|
+
typeMessage('Hello World!')
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
Additional parameters:
|
|
293
|
+
|
|
294
|
+
```js
|
|
295
|
+
const waitForPrevious = true // waits for previous message to be read, default: true
|
|
296
|
+
const hidden = true // message is not visible to the user, only the response is, default: false
|
|
297
|
+
const typingText = "Asking the unicorns' opinion..." // text to show in the loader while the Twin is answering, defaults to none
|
|
298
|
+
typeMessage('Hello World!', waitForPrevious, hidden, typingText)
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
There is also an alias function that does not show the message sent to the user, but only the Twin's response:
|
|
302
|
+
|
|
303
|
+
```js
|
|
304
|
+
const waitForPrevious = true // waits for previous message to be read, default: true
|
|
305
|
+
typeMessageHidden('Hello World!', waitForPrevious)
|
|
306
|
+
|
|
307
|
+
// alias to
|
|
308
|
+
typeMessage('Hello World!', waitForPrevious, true)
|
|
309
|
+
```
|
|
310
|
+
|
|
260
311
|
## See also
|
|
261
312
|
|
|
262
313
|
- [memori-api-client](https://github.com/memori-ai/memori-api-client) - API client for Memori
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
border-top-right-radius: 3px;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
.memori-chat--cover
|
|
52
|
+
.memori-chat--cover+.memori-chat--bubble-initial {
|
|
53
53
|
display: none;
|
|
54
54
|
}
|
|
55
55
|
|
|
@@ -103,7 +103,7 @@
|
|
|
103
103
|
white-space: nowrap;
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
-
.memori-chat--context-tag
|
|
106
|
+
.memori-chat--context-tag+.memori-chat--context-tag {
|
|
107
107
|
margin-top: 0.5rem;
|
|
108
108
|
}
|
|
109
109
|
|
|
@@ -115,4 +115,4 @@
|
|
|
115
115
|
|
|
116
116
|
.memori-chat--known-tag {
|
|
117
117
|
margin-right: 0.5rem;
|
|
118
|
-
}
|
|
118
|
+
}
|
|
@@ -10,7 +10,8 @@ const ChatBubble_1 = tslib_1.__importDefault(require("../ChatBubble/ChatBubble")
|
|
|
10
10
|
const MediaWidget_1 = tslib_1.__importDefault(require("../MediaWidget/MediaWidget"));
|
|
11
11
|
const Button_1 = tslib_1.__importDefault(require("../ui/Button"));
|
|
12
12
|
const ChatInputs_1 = tslib_1.__importDefault(require("../ChatInputs/ChatInputs"));
|
|
13
|
-
const
|
|
13
|
+
const Typing_1 = tslib_1.__importDefault(require("../Typing/Typing"));
|
|
14
|
+
const Chat = ({ memori, tenant, sessionID, baseUrl, apiUrl, translateTo, memoriTyping, showTypingText = false, history = [], authToken, dialogState, simulateUserPrompt, showDates = false, showContextPerLine = false, showAIicon = true, selectReceiverTag, preview = false, instruct = false, showInputs = true, showMicrophone = false, microphoneMode = 'HOLD_TO_TALK', sendOnEnter, setSendOnEnter, attachmentsMenuOpen, setAttachmentsMenuOpen, userMessage = '', onChangeUserMessage, sendMessage, listening, isPlayingAudio, stopAudio, startListening, stopListening, resetTranscript, customMediaRenderer, }) => {
|
|
14
15
|
var _a, _b, _c, _d, _e;
|
|
15
16
|
const scrollToBottom = () => {
|
|
16
17
|
setTimeout(() => {
|
|
@@ -90,12 +91,16 @@ const Chat = ({ memori, tenant, sessionID, baseUrl, apiUrl, translateTo, memoriT
|
|
|
90
91
|
var _a, _b, _c;
|
|
91
92
|
return ((_a = message.contextVars) === null || _a === void 0 ? void 0 : _a[key]) === '-' ? ((0, jsx_runtime_1.jsx)("div", { className: `memori-chat--context-tag memori-chat--context-tag-canceled`, children: (0, jsx_runtime_1.jsx)("span", { className: "memori-chat--context-tag-text", children: key }) }, key)) : ((_b = message.contextVars) === null || _b === void 0 ? void 0 : _b[key]) === '✔️' ? ((0, jsx_runtime_1.jsx)("div", { className: "memori-chat--context-tag", children: (0, jsx_runtime_1.jsx)("span", { className: "memori-chat--context-tag-text", children: key }) }, key)) : ((0, jsx_runtime_1.jsx)("div", { className: "memori-chat--context-tag", children: (0, jsx_runtime_1.jsxs)("span", { className: "memori-chat--context-tag-text", children: [key, ": ", (_c = message.contextVars) === null || _c === void 0 ? void 0 : _c[key]] }) }, key));
|
|
92
93
|
}) })), (0, jsx_runtime_1.jsx)(MediaWidget_1.default, { simulateUserPrompt: simulateUserPrompt, media: (_c = message === null || message === void 0 ? void 0 : message.media) === null || _c === void 0 ? void 0 : _c.filter(m => m.mimeType !== 'text/html' && m.mimeType !== 'text/plain'), links: (_d = message === null || message === void 0 ? void 0 : message.media) === null || _d === void 0 ? void 0 : _d.filter(m => m.mimeType === 'text/html'), sessionID: sessionID, baseUrl: baseUrl, apiUrl: apiUrl, translateTo: translateTo, customMediaRenderer: customMediaRenderer })] }, index));
|
|
93
|
-
}),
|
|
94
|
+
}), (dialogState === null || dialogState === void 0 ? void 0 : dialogState.hints) && dialogState.hints.length > 0 && ((0, jsx_runtime_1.jsx)(MediaWidget_1.default, { simulateUserPrompt: simulateUserPrompt, hints: dialogState.translatedHints
|
|
94
95
|
? dialogState.translatedHints
|
|
95
96
|
: dialogState.hints.map(h => ({
|
|
96
97
|
text: h,
|
|
97
98
|
originalText: h,
|
|
98
|
-
})) })),
|
|
99
|
+
})) })), !!memoriTyping && ((0, jsx_runtime_1.jsx)(Typing_1.default, { useDefaultSentences: showTypingText, lang: translateTo
|
|
100
|
+
? translateTo.toLowerCase() === 'it'
|
|
101
|
+
? 'it'
|
|
102
|
+
: 'en'
|
|
103
|
+
: 'en', sentence: typeof memoriTyping === 'string' ? memoriTyping : undefined })), (0, jsx_runtime_1.jsx)("div", { id: "end-messages-ref" })] }) }), (dialogState === null || dialogState === void 0 ? void 0 : dialogState.state) === 'X3' && sessionID && ((0, jsx_runtime_1.jsx)("div", { className: "memori-chat--known-tags", children: Object.keys((_e = dialogState.knownTags) !== null && _e !== void 0 ? _e : {})
|
|
99
104
|
.filter(t => t !== memori.giverTag)
|
|
100
105
|
.map(tag => {
|
|
101
106
|
var _a;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chat.js","sourceRoot":"","sources":["../../../src/components/Chat/Chat.tsx"],"names":[],"mappings":";;;;AAAA,uDAA+C;AAC/C,oEAA4B;AAO5B,+CAAqD;AACrD,+CAAqD;AACrD,kFAAkD;AAClD,qFAEoC;AACpC,kEAAkC;AAElC,kFAAkD;
|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EAAE,mBAAmB,EACxC,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,WAAW,EACxB,cAAc,EAAE,cAAc,EAC9B,WAAW,EAAE,WAAW,EACxB,cAAc,EAAE,cAAc,EAC9B,mBAAmB,EAAE,mBAAmB,EACxC,sBAAsB,EAAE,sBAAsB,EAC9C,oBAAoB,EAAE,oBAAoB,EAC1C,eAAe,EAAE,eAAe,EAChC,cAAc,EAAE,cAAc,EAC9B,cAAc,EAAE,cAAc,EAC9B,aAAa,EAAE,aAAa,EAC5B,SAAS,EAAE,SAAS,EACpB,SAAS,EAAE,SAAS,EACpB,cAAc,EAAE,cAAc,EAC9B,cAAc,EAAE,cAAc,GAC9B,CACH,IACG,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,IAAA,YAAI,EAAC,IAAI,CAAC,CAAC"}
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
|
|
36
36
|
.memori-chat--bubble #wave {
|
|
37
37
|
position: relative;
|
|
38
|
-
width:
|
|
38
|
+
width: 50px;
|
|
39
39
|
margin-right: auto;
|
|
40
40
|
margin-left: auto;
|
|
41
41
|
text-align: center;
|
|
@@ -43,8 +43,8 @@
|
|
|
43
43
|
|
|
44
44
|
.memori-chat--bubble #wave .dot {
|
|
45
45
|
display: inline-block;
|
|
46
|
-
width:
|
|
47
|
-
height:
|
|
46
|
+
width: 6px;
|
|
47
|
+
height: 6px;
|
|
48
48
|
border-radius: 50%;
|
|
49
49
|
margin-right: 3px;
|
|
50
50
|
animation: wave 1.5s linear infinite;
|
|
@@ -59,12 +59,16 @@
|
|
|
59
59
|
animation-delay: -1.1s;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
+
.memori-chat--bubble-typing {
|
|
63
|
+
display: flex;
|
|
64
|
+
}
|
|
65
|
+
|
|
62
66
|
.memori-chat--bubble p {
|
|
63
67
|
margin-top: 0;
|
|
64
68
|
margin-bottom: 0;
|
|
65
69
|
}
|
|
66
70
|
|
|
67
|
-
.memori-chat--bubble p
|
|
71
|
+
.memori-chat--bubble p+p {
|
|
68
72
|
margin-top: 0.5em;
|
|
69
73
|
}
|
|
70
74
|
|
|
@@ -215,6 +219,7 @@
|
|
|
215
219
|
}
|
|
216
220
|
|
|
217
221
|
@keyframes wave {
|
|
222
|
+
|
|
218
223
|
0%,
|
|
219
224
|
60%,
|
|
220
225
|
100% {
|
|
@@ -224,4 +229,4 @@
|
|
|
224
229
|
30% {
|
|
225
230
|
transform: translateY(-10px);
|
|
226
231
|
}
|
|
227
|
-
}
|
|
232
|
+
}
|
|
@@ -10,9 +10,10 @@ type MemoriTextEnteredEvent = CustomEvent<{
|
|
|
10
10
|
text: string;
|
|
11
11
|
waitForPrevious?: boolean;
|
|
12
12
|
hidden?: boolean;
|
|
13
|
+
typingText?: string;
|
|
13
14
|
}>;
|
|
14
|
-
declare const typeMessage: (message: string, waitForPrevious?: boolean, hidden?: boolean) => void;
|
|
15
|
-
declare const typeMessageHidden: (message: string, waitForPrevious?: boolean) => void;
|
|
15
|
+
declare const typeMessage: (message: string, waitForPrevious?: boolean, hidden?: boolean, typingText?: string | undefined) => void;
|
|
16
|
+
declare const typeMessageHidden: (message: string, waitForPrevious?: boolean, typingText?: string | undefined) => void;
|
|
16
17
|
interface CustomEventMap {
|
|
17
18
|
MemoriTextEntered: MemoriTextEnteredEvent;
|
|
18
19
|
}
|
|
@@ -61,6 +62,7 @@ export interface Props {
|
|
|
61
62
|
showDates?: boolean;
|
|
62
63
|
showContextPerLine?: boolean;
|
|
63
64
|
showSettings?: boolean;
|
|
65
|
+
showTypingText?: boolean;
|
|
64
66
|
preview?: boolean;
|
|
65
67
|
embed?: boolean;
|
|
66
68
|
height?: number | string;
|
|
@@ -88,5 +90,5 @@ export interface Props {
|
|
|
88
90
|
customMediaRenderer?: ChatProps['customMediaRenderer'];
|
|
89
91
|
additionalSettings?: JSX.Element | null;
|
|
90
92
|
}
|
|
91
|
-
declare const
|
|
92
|
-
export default
|
|
93
|
+
declare const MemoriWidget: ({ memori, memoriConfigs, memoriLang, multilingual, integration, layout, customLayout, showInstruct, showShare, preview, embed, showInputs, showDates, showContextPerLine, showSettings, showTypingText, height, secret, baseUrl, apiUrl, initialContextVars, initialQuestion, ogImage, sessionID: initialSessionID, tenant, personification, authToken, AZURE_COGNITIVE_SERVICES_TTS_KEY, onStateChange, additionalInfo, additionalSettings, customMediaRenderer, }: Props) => JSX.Element;
|
|
94
|
+
export default MemoriWidget;
|
|
@@ -46,17 +46,18 @@ const getMemoriState = (integrationId) => {
|
|
|
46
46
|
let dialogState = JSON.parse(engineState);
|
|
47
47
|
return dialogState;
|
|
48
48
|
};
|
|
49
|
-
const typeMessage = (message, waitForPrevious = true, hidden = false) => {
|
|
49
|
+
const typeMessage = (message, waitForPrevious = true, hidden = false, typingText) => {
|
|
50
50
|
const e = new CustomEvent('MemoriTextEntered', {
|
|
51
51
|
detail: {
|
|
52
52
|
text: message,
|
|
53
53
|
waitForPrevious,
|
|
54
54
|
hidden,
|
|
55
|
+
typingText,
|
|
55
56
|
},
|
|
56
57
|
});
|
|
57
58
|
document.dispatchEvent(e);
|
|
58
59
|
};
|
|
59
|
-
const typeMessageHidden = (message, waitForPrevious = true) => typeMessage(message, waitForPrevious, true);
|
|
60
|
+
const typeMessageHidden = (message, waitForPrevious = true, typingText) => typeMessage(message, waitForPrevious, true, typingText);
|
|
60
61
|
window.getMemoriState = getMemoriState;
|
|
61
62
|
window.typeMessage = typeMessage;
|
|
62
63
|
window.typeMessageHidden = typeMessageHidden;
|
|
@@ -68,7 +69,7 @@ let audioContext;
|
|
|
68
69
|
let memoriPassword;
|
|
69
70
|
let speakerMuted = false;
|
|
70
71
|
let memoriSpeaking = false;
|
|
71
|
-
const MemoriWidget = ({ memori, memoriConfigs, memoriLang, multilingual, integration, layout = 'DEFAULT', customLayout, showInstruct = false, showShare, preview = false, embed = false, showInputs = true, showDates = false, showContextPerLine = false, showSettings = true, height = '100vh', secret, baseUrl = 'https://app.twincreator.com', apiUrl = 'https://backend.memori.ai', initialContextVars, initialQuestion, ogImage, sessionID: initialSessionID, tenant, personification, authToken, AZURE_COGNITIVE_SERVICES_TTS_KEY, onStateChange, additionalInfo, additionalSettings, customMediaRenderer, }) => {
|
|
72
|
+
const MemoriWidget = ({ memori, memoriConfigs, memoriLang, multilingual, integration, layout = 'DEFAULT', customLayout, showInstruct = false, showShare, preview = false, embed = false, showInputs = true, showDates = false, showContextPerLine = false, showSettings = true, showTypingText = false, height = '100vh', secret, baseUrl = 'https://app.twincreator.com', apiUrl = 'https://backend.memori.ai', initialContextVars, initialQuestion, ogImage, sessionID: initialSessionID, tenant, personification, authToken, AZURE_COGNITIVE_SERVICES_TTS_KEY, onStateChange, additionalInfo, additionalSettings, customMediaRenderer, }) => {
|
|
72
73
|
var _a, _b, _c, _d, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _t, _u, _v, _w, _x, _y;
|
|
73
74
|
const { t, i18n } = (0, react_i18next_1.useTranslation)();
|
|
74
75
|
const [isClient, setIsClient] = (0, react_1.useState)(false);
|
|
@@ -175,7 +176,7 @@ const MemoriWidget = ({ memori, memoriConfigs, memoriLang, multilingual, integra
|
|
|
175
176
|
];
|
|
176
177
|
});
|
|
177
178
|
};
|
|
178
|
-
const sendMessage = async (text, media, newSessionId, translate = true, translatedText, hidden = false) => {
|
|
179
|
+
const sendMessage = async (text, media, newSessionId, translate = true, translatedText, hidden = false, typingText) => {
|
|
179
180
|
var _a, _b;
|
|
180
181
|
const sessionID = newSessionId ||
|
|
181
182
|
sessionId ||
|
|
@@ -192,7 +193,7 @@ const MemoriWidget = ({ memori, memoriConfigs, memoriLang, multilingual, integra
|
|
|
192
193
|
? !!newSessionId && newSessionId !== sessionId
|
|
193
194
|
: !!newSessionId,
|
|
194
195
|
});
|
|
195
|
-
setMemoriTyping(true);
|
|
196
|
+
setMemoriTyping(typingText !== null && typingText !== void 0 ? typingText : true);
|
|
196
197
|
let msg = text;
|
|
197
198
|
if (translate &&
|
|
198
199
|
!instruct &&
|
|
@@ -393,7 +394,7 @@ const MemoriWidget = ({ memori, memoriConfigs, memoriLang, multilingual, integra
|
|
|
393
394
|
});
|
|
394
395
|
};
|
|
395
396
|
const fetchSession = async (params) => {
|
|
396
|
-
var _a;
|
|
397
|
+
var _a, _b;
|
|
397
398
|
if (memori.privacyType !== 'PUBLIC' &&
|
|
398
399
|
!memori.secretToken &&
|
|
399
400
|
!memoriPwd &&
|
|
@@ -428,6 +429,7 @@ const MemoriWidget = ({ memori, memoriConfigs, memoriLang, multilingual, integra
|
|
|
428
429
|
...params,
|
|
429
430
|
additionalInfo: {
|
|
430
431
|
...(additionalInfo || {}),
|
|
432
|
+
loginToken: (_b = additionalInfo === null || additionalInfo === void 0 ? void 0 : additionalInfo.loginToken) !== null && _b !== void 0 ? _b : authToken,
|
|
431
433
|
language: getCultureCodeByLanguage(userLang),
|
|
432
434
|
referral: referral,
|
|
433
435
|
},
|
|
@@ -461,7 +463,7 @@ const MemoriWidget = ({ memori, memoriConfigs, memoriLang, multilingual, integra
|
|
|
461
463
|
}
|
|
462
464
|
};
|
|
463
465
|
const reopenSession = async (updateDialogState = false, password, recoveryTokens, tag, pin, initialContextVars, initialQuestion, birthDate) => {
|
|
464
|
-
var _a;
|
|
466
|
+
var _a, _b;
|
|
465
467
|
setLoading(true);
|
|
466
468
|
try {
|
|
467
469
|
if (memori.privacyType !== 'PUBLIC' &&
|
|
@@ -498,6 +500,7 @@ const MemoriWidget = ({ memori, memoriConfigs, memoriLang, multilingual, integra
|
|
|
498
500
|
birthDate: birthDate || storageBirthDate || undefined,
|
|
499
501
|
additionalInfo: {
|
|
500
502
|
...(additionalInfo || {}),
|
|
503
|
+
loginToken: (_b = additionalInfo === null || additionalInfo === void 0 ? void 0 : additionalInfo.loginToken) !== null && _b !== void 0 ? _b : authToken,
|
|
501
504
|
language: getCultureCodeByLanguage(userLang),
|
|
502
505
|
referral: referral,
|
|
503
506
|
},
|
|
@@ -548,7 +551,7 @@ const MemoriWidget = ({ memori, memoriConfigs, memoriLang, multilingual, integra
|
|
|
548
551
|
return null;
|
|
549
552
|
};
|
|
550
553
|
const changeTag = async (memoriId, sessionId, tag, pin) => {
|
|
551
|
-
var _a;
|
|
554
|
+
var _a, _b;
|
|
552
555
|
if (!memoriId || !sessionId) {
|
|
553
556
|
console.error('CHANGETAG/Session not found');
|
|
554
557
|
return Promise.reject('Session not found');
|
|
@@ -598,6 +601,7 @@ const MemoriWidget = ({ memori, memoriConfigs, memoriLang, multilingual, integra
|
|
|
598
601
|
birthDate: birthDate || storageBirthDate || undefined,
|
|
599
602
|
additionalInfo: {
|
|
600
603
|
...(additionalInfo || {}),
|
|
604
|
+
loginToken: (_b = additionalInfo === null || additionalInfo === void 0 ? void 0 : additionalInfo.loginToken) !== null && _b !== void 0 ? _b : authToken,
|
|
601
605
|
language: getCultureCodeByLanguage(userLang),
|
|
602
606
|
referral: referral,
|
|
603
607
|
},
|
|
@@ -659,7 +663,7 @@ const MemoriWidget = ({ memori, memoriConfigs, memoriLang, multilingual, integra
|
|
|
659
663
|
if (!!speechSynthesizer ||
|
|
660
664
|
isPlayingAudio ||
|
|
661
665
|
!!userMessage.length ||
|
|
662
|
-
memoriTyping ||
|
|
666
|
+
!!memoriTyping ||
|
|
663
667
|
listening) {
|
|
664
668
|
resetInteractionTimeout();
|
|
665
669
|
return;
|
|
@@ -715,7 +719,7 @@ const MemoriWidget = ({ memori, memoriConfigs, memoriLang, multilingual, integra
|
|
|
715
719
|
timeoutRef.current = uiTimeout;
|
|
716
720
|
};
|
|
717
721
|
(0, react_1.useEffect)(() => {
|
|
718
|
-
if (!!userMessage.length || isPlayingAudio || memoriTyping)
|
|
722
|
+
if (!!userMessage.length || isPlayingAudio || !!memoriTyping)
|
|
719
723
|
clearInteractionTimeout();
|
|
720
724
|
if (sessionId && !!!userMessage.length)
|
|
721
725
|
resetInteractionTimeout();
|
|
@@ -1382,13 +1386,11 @@ const MemoriWidget = ({ memori, memoriConfigs, memoriLang, multilingual, integra
|
|
|
1382
1386
|
sendMessage(text, undefined, undefined, false, translatedText);
|
|
1383
1387
|
};
|
|
1384
1388
|
const memoriTextEnteredHandler = (0, react_1.useCallback)((e) => {
|
|
1385
|
-
|
|
1386
|
-
const { text, waitForPrevious, hidden } = e.detail;
|
|
1387
|
-
const sessionID = sessionId || ((_a = window.getMemoriState()) === null || _a === void 0 ? void 0 : _a.sessionID);
|
|
1389
|
+
const { text, waitForPrevious, hidden, typingText } = e.detail;
|
|
1388
1390
|
if (text) {
|
|
1389
1391
|
if (waitForPrevious &&
|
|
1390
1392
|
!speakerMuted &&
|
|
1391
|
-
(memoriSpeaking || memoriTyping)) {
|
|
1393
|
+
(memoriSpeaking || !!memoriTyping)) {
|
|
1392
1394
|
setTimeout(() => {
|
|
1393
1395
|
memoriTextEnteredHandler(e);
|
|
1394
1396
|
}, 1000);
|
|
@@ -1396,7 +1398,7 @@ const MemoriWidget = ({ memori, memoriConfigs, memoriLang, multilingual, integra
|
|
|
1396
1398
|
else {
|
|
1397
1399
|
stopListening();
|
|
1398
1400
|
stopAudio();
|
|
1399
|
-
sendMessage(text, undefined, undefined, undefined, undefined, hidden);
|
|
1401
|
+
sendMessage(text, undefined, undefined, undefined, undefined, hidden, typingText);
|
|
1400
1402
|
}
|
|
1401
1403
|
}
|
|
1402
1404
|
}, [sessionId, isPlayingAudio, memoriTyping, userLang]);
|
|
@@ -1658,7 +1660,7 @@ const MemoriWidget = ({ memori, memoriConfigs, memoriLang, multilingual, integra
|
|
|
1658
1660
|
setAvatar3dVisible,
|
|
1659
1661
|
hasUserActivatedSpeak,
|
|
1660
1662
|
isPlayingAudio,
|
|
1661
|
-
loading: memoriTyping,
|
|
1663
|
+
loading: !!memoriTyping,
|
|
1662
1664
|
baseUrl,
|
|
1663
1665
|
apiUrl,
|
|
1664
1666
|
};
|
|
@@ -1692,6 +1694,7 @@ const MemoriWidget = ({ memori, memoriConfigs, memoriLang, multilingual, integra
|
|
|
1692
1694
|
baseUrl,
|
|
1693
1695
|
apiUrl,
|
|
1694
1696
|
memoriTyping,
|
|
1697
|
+
showTypingText,
|
|
1695
1698
|
history: layout === 'TOTEM' ? history.slice(-2) : history,
|
|
1696
1699
|
authToken: loginToken,
|
|
1697
1700
|
dialogState: currentDialogState,
|
|
@@ -1878,5 +1881,5 @@ const MemoriWidget = ({ memori, memoriConfigs, memoriLang, multilingual, integra
|
|
|
1878
1881
|
setAttachmentsMenuOpen(undefined);
|
|
1879
1882
|
} }))] }));
|
|
1880
1883
|
};
|
|
1881
|
-
exports.default =
|
|
1884
|
+
exports.default = MemoriWidget;
|
|
1882
1885
|
//# sourceMappingURL=MemoriWidget.js.map
|