@memori.ai/memori-react 8.41.2 → 8.41.4
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 +23 -0
- package/dist/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/fullbodyAvatar.js +8 -1
- package/dist/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/fullbodyAvatar.js.map +1 -1
- package/dist/components/Avatar/AvatarView/AvatarComponent/components/controllers/MorphTargetController.js +1 -1
- package/dist/components/Avatar/AvatarView/AvatarComponent/components/controllers/MorphTargetController.js.map +1 -1
- package/dist/components/Avatar/AvatarView/AvatarComponent/constants.d.ts +2 -0
- package/dist/components/Avatar/AvatarView/AvatarComponent/constants.js +14 -5
- package/dist/components/Avatar/AvatarView/AvatarComponent/constants.js.map +1 -1
- package/dist/components/ChatBubble/ChatBubble.js +16 -11
- package/dist/components/ChatBubble/ChatBubble.js.map +1 -1
- package/dist/components/MemoriWidget/MemoriWidget.js +121 -84
- package/dist/components/MemoriWidget/MemoriWidget.js.map +1 -1
- package/dist/components/UploadButton/UploadDocuments/UploadDocuments.js +79 -52
- package/dist/components/UploadButton/UploadDocuments/UploadDocuments.js.map +1 -1
- package/dist/helpers/constants.d.ts +1 -1
- package/dist/helpers/constants.js +0 -1
- package/dist/helpers/constants.js.map +1 -1
- package/dist/helpers/utils.d.ts +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/esm/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/fullbodyAvatar.js +9 -2
- package/esm/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/fullbodyAvatar.js.map +1 -1
- package/esm/components/Avatar/AvatarView/AvatarComponent/components/controllers/MorphTargetController.js +2 -2
- package/esm/components/Avatar/AvatarView/AvatarComponent/components/controllers/MorphTargetController.js.map +1 -1
- package/esm/components/Avatar/AvatarView/AvatarComponent/constants.d.ts +2 -0
- package/esm/components/Avatar/AvatarView/AvatarComponent/constants.js +13 -4
- package/esm/components/Avatar/AvatarView/AvatarComponent/constants.js.map +1 -1
- package/esm/components/ChatBubble/ChatBubble.js +16 -11
- package/esm/components/ChatBubble/ChatBubble.js.map +1 -1
- package/esm/components/MemoriWidget/MemoriWidget.js +121 -84
- package/esm/components/MemoriWidget/MemoriWidget.js.map +1 -1
- package/esm/components/UploadButton/UploadDocuments/UploadDocuments.js +79 -52
- package/esm/components/UploadButton/UploadDocuments/UploadDocuments.js.map +1 -1
- package/esm/helpers/constants.d.ts +1 -1
- package/esm/helpers/constants.js +0 -1
- package/esm/helpers/constants.js.map +1 -1
- package/esm/helpers/utils.d.ts +1 -1
- package/esm/version.d.ts +1 -1
- package/esm/version.js +1 -1
- package/package.json +1 -1
- package/src/components/Avatar/Avatar.test.tsx +27 -0
- package/src/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/fullbodyAvatar.tsx +12 -5
- package/src/components/Avatar/AvatarView/AvatarComponent/components/controllers/MorphTargetController.ts +2 -1
- package/src/components/Avatar/AvatarView/AvatarComponent/constants.ts +16 -4
- package/src/components/Avatar/__snapshots__/Avatar.test.tsx.snap +63 -0
- package/src/components/ChatBubble/ChatBubble.tsx +28 -3
- package/src/components/MemoriWidget/MemoriWidget.tsx +110 -68
- package/src/components/UploadButton/UploadDocuments/UploadDocuments.tsx +103 -55
- package/src/components/UploadButton/__snapshots__/UploadButton.test.tsx.snap +2 -2
- package/src/components/layouts/layouts.stories.tsx +6 -13
- package/src/helpers/constants.ts +0 -1
- package/src/helpers/utils.test.ts +1 -1
- package/src/version.ts +1 -1
|
@@ -61,6 +61,10 @@ const getMemoriState = (integrationId) => {
|
|
|
61
61
|
loginToken,
|
|
62
62
|
};
|
|
63
63
|
};
|
|
64
|
+
const resolveLoginTokenValue = (loginToken, userTokenRef, callAdditionalInfoLoginToken, additionalInfoLoginToken, authTokenProp) => {
|
|
65
|
+
var _a, _b, _c;
|
|
66
|
+
return (_c = (_b = (_a = loginToken !== null && loginToken !== void 0 ? loginToken : userTokenRef) !== null && _a !== void 0 ? _a : callAdditionalInfoLoginToken) !== null && _b !== void 0 ? _b : additionalInfoLoginToken) !== null && _c !== void 0 ? _c : authTokenProp;
|
|
67
|
+
};
|
|
64
68
|
const NULL_PLACE_SPEC = {
|
|
65
69
|
placeName: null,
|
|
66
70
|
latitude: null,
|
|
@@ -169,7 +173,6 @@ window.typeMessageHidden = typeMessageHidden;
|
|
|
169
173
|
window.typeBatchMessages = typeBatchMessages;
|
|
170
174
|
let audioContext;
|
|
171
175
|
let memoriPassword;
|
|
172
|
-
let userToken;
|
|
173
176
|
const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenantID, memoriLang, uiLang, spokenLang, multilingual, integration, layout, customLayout, showShare, preview = false, embed = false, showCopyButton = true, showTranslationOriginal = false, showInputs = true, showDates = false, showContextPerLine = false, showMessageConsumption = false, showSettings, showTypingText = false, showClear = false, showLogin = false, showUpload, showOnlyLastMessages, showChatHistory, showReasoning, avatar3dHidden, height = '100vh', secret, baseUrl = 'https://aisuru-staging.aclambda.online', apiURL = 'https://backend-staging.memori.ai', engineURL = 'https://engine-staging.memori.ai', initialContextVars, initialQuestion, ttsProvider, ogImage, sessionID: initialSessionID, tenant, personification, authToken, enableAudio, defaultSpeakerActive = true, disableTextEnteredEvents = false, onStateChange, additionalInfo, additionalSettings, customMediaRenderer, userAvatar, __WEBCOMPONENT__ = false, useMathFormatting = false, autoStart = false, applyVarsToRoot = false, showFunctionCache = false, maxTotalMessagePayload, maxTextareaCharacters, }) => {
|
|
174
177
|
var _a, _b, _c, _d, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18;
|
|
175
178
|
const { t, i18n } = useTranslation();
|
|
@@ -182,35 +185,61 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
182
185
|
const [instruct, setInstruct] = useState(false);
|
|
183
186
|
const [enableFocusChatInput, setEnableFocusChatInput] = useState(true);
|
|
184
187
|
const [loginToken, setLoginToken] = useState((_a = additionalInfo === null || additionalInfo === void 0 ? void 0 : additionalInfo.loginToken) !== null && _a !== void 0 ? _a : authToken);
|
|
188
|
+
const userTokenRef = useRef((_b = additionalInfo === null || additionalInfo === void 0 ? void 0 : additionalInfo.loginToken) !== null && _b !== void 0 ? _b : authToken);
|
|
189
|
+
const prevPropsLoginTokenRef = useRef((_c = additionalInfo === null || additionalInfo === void 0 ? void 0 : additionalInfo.loginToken) !== null && _c !== void 0 ? _c : authToken);
|
|
185
190
|
const [user, setUser] = useState({
|
|
186
191
|
avatarURL: typeof userAvatar === 'string' ? userAvatar : undefined,
|
|
187
192
|
});
|
|
193
|
+
const resolveLoginToken = useCallback((callAdditionalInfoLoginToken) => resolveLoginTokenValue(loginToken, userTokenRef.current, callAdditionalInfoLoginToken, additionalInfo === null || additionalInfo === void 0 ? void 0 : additionalInfo.loginToken, authToken), [loginToken, additionalInfo === null || additionalInfo === void 0 ? void 0 : additionalInfo.loginToken, authToken]);
|
|
188
194
|
useEffect(() => {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
}
|
|
206
|
-
});
|
|
195
|
+
var _a;
|
|
196
|
+
const incomingToken = (_a = additionalInfo === null || additionalInfo === void 0 ? void 0 : additionalInfo.loginToken) !== null && _a !== void 0 ? _a : authToken;
|
|
197
|
+
const prevPropsToken = prevPropsLoginTokenRef.current;
|
|
198
|
+
prevPropsLoginTokenRef.current = incomingToken;
|
|
199
|
+
if (incomingToken !== prevPropsToken) {
|
|
200
|
+
setLoginToken(incomingToken);
|
|
201
|
+
userTokenRef.current = incomingToken;
|
|
202
|
+
if (!incomingToken) {
|
|
203
|
+
removeLocalConfig('loginToken');
|
|
204
|
+
setUser(undefined);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}, [additionalInfo === null || additionalInfo === void 0 ? void 0 : additionalInfo.loginToken, authToken]);
|
|
208
|
+
useEffect(() => {
|
|
209
|
+
if (!loginToken || !(showLogin || memori.requireLoginToken)) {
|
|
210
|
+
return;
|
|
207
211
|
}
|
|
208
|
-
|
|
212
|
+
let cancelled = false;
|
|
213
|
+
client.backend
|
|
214
|
+
.pwlGetCurrentUser(loginToken)
|
|
215
|
+
.then(({ user: fetchedUser, resultCode }) => {
|
|
216
|
+
if (cancelled)
|
|
217
|
+
return;
|
|
218
|
+
if (fetchedUser && resultCode === 0) {
|
|
219
|
+
setUser(fetchedUser);
|
|
220
|
+
setLocalConfig('loginToken', loginToken);
|
|
221
|
+
userTokenRef.current = loginToken;
|
|
222
|
+
if (!birthDate && fetchedUser.birthDate) {
|
|
223
|
+
setBirthDate(fetchedUser.birthDate);
|
|
224
|
+
setLocalConfig('birthDate', fetchedUser.birthDate);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
setLoginToken(undefined);
|
|
229
|
+
userTokenRef.current = undefined;
|
|
230
|
+
setUser(undefined);
|
|
231
|
+
removeLocalConfig('loginToken');
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
return () => {
|
|
235
|
+
cancelled = true;
|
|
236
|
+
};
|
|
237
|
+
}, [loginToken, showLogin, memori.requireLoginToken]);
|
|
209
238
|
const [showLoginDrawer, setShowLoginDrawer] = useState(false);
|
|
210
239
|
const [clickedStart, setClickedStart] = useState(false);
|
|
211
240
|
const sessionStartingRef = useRef(false);
|
|
212
|
-
const language = ((
|
|
213
|
-
((
|
|
241
|
+
const language = ((_g = (_f = (_d = memori.culture) === null || _d === void 0 ? void 0 : _d.split('-')) === null || _f === void 0 ? void 0 : _f[0]) === null || _g === void 0 ? void 0 : _g.toUpperCase()) ||
|
|
242
|
+
((_l = (_k = (_j = (_h = memoriConfigs === null || memoriConfigs === void 0 ? void 0 : memoriConfigs.find(c => c.memoriConfigID === memori.memoriConfigurationID)) === null || _h === void 0 ? void 0 : _h.culture) === null || _j === void 0 ? void 0 : _j.split('-')) === null || _k === void 0 ? void 0 : _k[0]) === null || _l === void 0 ? void 0 : _l.toUpperCase());
|
|
214
243
|
const integrationConfig = (integration === null || integration === void 0 ? void 0 : integration.customData)
|
|
215
244
|
? JSON.parse(integration.customData)
|
|
216
245
|
: null;
|
|
@@ -218,7 +247,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
218
247
|
? multilingual
|
|
219
248
|
: !!(integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.multilanguage);
|
|
220
249
|
const forcedTimeout = integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.forcedTimeout;
|
|
221
|
-
const [userLang, setUserLang] = useState((
|
|
250
|
+
const [userLang, setUserLang] = useState((_r = (_q = (_p = (_o = (_m = spokenLang !== null && spokenLang !== void 0 ? spokenLang : memoriLang) !== null && _m !== void 0 ? _m : integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.lang) !== null && _o !== void 0 ? _o : language) !== null && _p !== void 0 ? _p : integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.uiLang) !== null && _q !== void 0 ? _q : i18n.language) !== null && _r !== void 0 ? _r : 'IT');
|
|
222
251
|
useEffect(() => {
|
|
223
252
|
if (spokenLang != null) {
|
|
224
253
|
setUserLang(spokenLang);
|
|
@@ -250,14 +279,14 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
250
279
|
? layout
|
|
251
280
|
: typeof (integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.layout) === 'string'
|
|
252
281
|
? integrationConfig.layout
|
|
253
|
-
: (
|
|
282
|
+
: (_s = integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.layout) === null || _s === void 0 ? void 0 : _s.name;
|
|
254
283
|
const selectedLayout = layoutName || 'DEFAULT';
|
|
255
284
|
const piiDetection = typeof (integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.layout) === 'object' &&
|
|
256
285
|
(integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.layout) !== null &&
|
|
257
|
-
((
|
|
286
|
+
((_u = (_t = integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.layout) === null || _t === void 0 ? void 0 : _t.piiDetection) === null || _u === void 0 ? void 0 : _u.enabled)
|
|
258
287
|
? integrationConfig.layout.piiDetection
|
|
259
288
|
: undefined;
|
|
260
|
-
const defaultEnableAudio = (
|
|
289
|
+
const defaultEnableAudio = (_v = enableAudio !== null && enableAudio !== void 0 ? enableAudio : integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.enableAudio) !== null && _v !== void 0 ? _v : true;
|
|
261
290
|
const [hasUserActivatedListening, setHasUserActivatedListening] = useState(false);
|
|
262
291
|
const [hasUserTypedMessage, setHasUserTypedMessage] = useState(false);
|
|
263
292
|
const [showPositionDrawer, setShowPositionDrawer] = useState(false);
|
|
@@ -300,7 +329,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
300
329
|
setRuntimeShowMessageConsumption(getLocalConfig('showMessageConsumption', (_a = showMessageConsumption !== null && showMessageConsumption !== void 0 ? showMessageConsumption : integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.showMessageConsumption) !== null && _a !== void 0 ? _a : false));
|
|
301
330
|
if (!(additionalInfo === null || additionalInfo === void 0 ? void 0 : additionalInfo.loginToken) && !authToken) {
|
|
302
331
|
setLoginToken(getLocalConfig('loginToken', undefined));
|
|
303
|
-
|
|
332
|
+
userTokenRef.current = getLocalConfig('loginToken', undefined);
|
|
304
333
|
setBirthDate(getLocalConfig('birthDate', undefined));
|
|
305
334
|
}
|
|
306
335
|
if (!((_b = enableAudio !== null && enableAudio !== void 0 ? enableAudio : integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.enableAudio) !== null && _b !== void 0 ? _b : true)) {
|
|
@@ -719,7 +748,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
719
748
|
}
|
|
720
749
|
}, [initialSessionID]);
|
|
721
750
|
const fetchSession = async (params) => {
|
|
722
|
-
var _a, _b, _c, _d, _f, _g, _h
|
|
751
|
+
var _a, _b, _c, _d, _f, _g, _h;
|
|
723
752
|
let storageBirthDate = getLocalConfig('birthDate', undefined);
|
|
724
753
|
let userBirthDate = (_a = birthDate !== null && birthDate !== void 0 ? birthDate : params.birthDate) !== null && _a !== void 0 ? _a : storageBirthDate;
|
|
725
754
|
if (!userBirthDate && !!minAge) {
|
|
@@ -744,7 +773,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
744
773
|
return window.location.href;
|
|
745
774
|
})();
|
|
746
775
|
}
|
|
747
|
-
catch (
|
|
776
|
+
catch (_j) {
|
|
748
777
|
}
|
|
749
778
|
const session = await initSession({
|
|
750
779
|
...params,
|
|
@@ -753,8 +782,8 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
753
782
|
pin: (_c = params.pin) !== null && _c !== void 0 ? _c : personification === null || personification === void 0 ? void 0 : personification.pin,
|
|
754
783
|
additionalInfo: {
|
|
755
784
|
...(params.additionalInfo || additionalInfo || {}),
|
|
756
|
-
loginToken: (
|
|
757
|
-
language: ((
|
|
785
|
+
loginToken: resolveLoginToken((_d = params.additionalInfo) === null || _d === void 0 ? void 0 : _d.loginToken),
|
|
786
|
+
language: ((_h = userLang !== null && userLang !== void 0 ? userLang : (_g = (_f = memori.culture) === null || _f === void 0 ? void 0 : _f.split('-')) === null || _g === void 0 ? void 0 : _g[0]) !== null && _h !== void 0 ? _h : 'IT').toLowerCase(),
|
|
758
787
|
referral: referral,
|
|
759
788
|
timeZoneOffset: new Date().getTimezoneOffset().toString(),
|
|
760
789
|
},
|
|
@@ -795,7 +824,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
795
824
|
}
|
|
796
825
|
};
|
|
797
826
|
const reopenSession = async (updateDialogState = false, password, recoveryTokens, tag, pin, initialContextVars, initialQuestion, birthDate, additionalInfoProp, continueFromChatLogID, continueFromSessionID, isSessionExpired, suppressHistoryUpdate) => {
|
|
798
|
-
var _a, _b, _c, _d, _f, _g, _h, _j
|
|
827
|
+
var _a, _b, _c, _d, _f, _g, _h, _j;
|
|
799
828
|
setLoading(true);
|
|
800
829
|
let storageBirthDate = getLocalConfig('birthDate', undefined);
|
|
801
830
|
let userBirthDate = birthDate !== null && birthDate !== void 0 ? birthDate : storageBirthDate;
|
|
@@ -823,7 +852,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
823
852
|
return window.location.href;
|
|
824
853
|
})();
|
|
825
854
|
}
|
|
826
|
-
catch (
|
|
855
|
+
catch (_k) {
|
|
827
856
|
}
|
|
828
857
|
const { sessionID, currentState, ...response } = await initSession({
|
|
829
858
|
memoriID: (_a = memori.engineMemoriID) !== null && _a !== void 0 ? _a : '',
|
|
@@ -843,8 +872,8 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
843
872
|
birthDate: userBirthDate,
|
|
844
873
|
additionalInfo: {
|
|
845
874
|
...(additionalInfoProp || additionalInfo || {}),
|
|
846
|
-
loginToken: (
|
|
847
|
-
language: ((
|
|
875
|
+
loginToken: resolveLoginToken(additionalInfoProp === null || additionalInfoProp === void 0 ? void 0 : additionalInfoProp.loginToken),
|
|
876
|
+
language: ((_g = userLang !== null && userLang !== void 0 ? userLang : (_f = (_d = memori.culture) === null || _d === void 0 ? void 0 : _d.split('-')) === null || _f === void 0 ? void 0 : _f[0]) !== null && _g !== void 0 ? _g : 'IT').toLowerCase(),
|
|
848
877
|
referral: referral,
|
|
849
878
|
timeZoneOffset: new Date().getTimezoneOffset().toString(),
|
|
850
879
|
},
|
|
@@ -877,7 +906,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
877
906
|
{
|
|
878
907
|
text: currentState.emission,
|
|
879
908
|
emitter: currentState.emitter,
|
|
880
|
-
media: (
|
|
909
|
+
media: (_h = currentState.emittedMedia) !== null && _h !== void 0 ? _h : currentState.media,
|
|
881
910
|
fromUser: false,
|
|
882
911
|
initial: (initialStatus === true
|
|
883
912
|
? true
|
|
@@ -895,7 +924,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
895
924
|
: pushMessage({
|
|
896
925
|
text: currentState.emission,
|
|
897
926
|
emitter: currentState.emitter,
|
|
898
|
-
media: (
|
|
927
|
+
media: (_j = currentState.emittedMedia) !== null && _j !== void 0 ? _j : currentState.media,
|
|
899
928
|
fromUser: false,
|
|
900
929
|
initial: (initialStatus === true
|
|
901
930
|
? true
|
|
@@ -980,7 +1009,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
980
1009
|
});
|
|
981
1010
|
};
|
|
982
1011
|
const changeTag = async (memoriId, sessionId, tag, pin) => {
|
|
983
|
-
var _a, _b, _c, _d, _f, _g, _h
|
|
1012
|
+
var _a, _b, _c, _d, _f, _g, _h;
|
|
984
1013
|
if (!memoriId || !sessionId) {
|
|
985
1014
|
return Promise.reject('Session not found');
|
|
986
1015
|
}
|
|
@@ -1020,7 +1049,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1020
1049
|
return window.location.href;
|
|
1021
1050
|
})();
|
|
1022
1051
|
}
|
|
1023
|
-
catch (
|
|
1052
|
+
catch (_j) {
|
|
1024
1053
|
}
|
|
1025
1054
|
fetchSession({
|
|
1026
1055
|
memoriID: (_b = memori.engineMemoriID) !== null && _b !== void 0 ? _b : '',
|
|
@@ -1037,8 +1066,8 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1037
1066
|
birthDate: birthDate || storageBirthDate || undefined,
|
|
1038
1067
|
additionalInfo: {
|
|
1039
1068
|
...(additionalInfo || {}),
|
|
1040
|
-
loginToken: (
|
|
1041
|
-
language: ((
|
|
1069
|
+
loginToken: resolveLoginToken(),
|
|
1070
|
+
language: ((_h = userLang !== null && userLang !== void 0 ? userLang : (_g = (_f = memori.culture) === null || _f === void 0 ? void 0 : _f.split('-')) === null || _g === void 0 ? void 0 : _g[0]) !== null && _h !== void 0 ? _h : 'IT').toLowerCase(),
|
|
1042
1071
|
referral: referral,
|
|
1043
1072
|
timeZoneOffset: new Date().getTimezoneOffset().toString(),
|
|
1044
1073
|
},
|
|
@@ -1102,7 +1131,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1102
1131
|
apiUrl: `${baseUrl}/api/tts`,
|
|
1103
1132
|
continuousSpeech: continuousSpeech,
|
|
1104
1133
|
preview: preview,
|
|
1105
|
-
}, autoStart, defaultEnableAudio, (
|
|
1134
|
+
}, autoStart, defaultEnableAudio, (_w = defaultSpeakerActive !== null && defaultSpeakerActive !== void 0 ? defaultSpeakerActive : integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.defaultSpeakerActive) !== null && _w !== void 0 ? _w : true);
|
|
1106
1135
|
const shouldPlayAudio = (text) => {
|
|
1107
1136
|
const currentSpeakerMuted = getLocalConfig('muteSpeaker', !defaultEnableAudio);
|
|
1108
1137
|
return (text &&
|
|
@@ -1450,7 +1479,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1450
1479
|
? {
|
|
1451
1480
|
'--memori-chat-bubble-bg': '#fff',
|
|
1452
1481
|
...(integrationConfig && !instruct
|
|
1453
|
-
? { '--memori-text-color': (
|
|
1482
|
+
? { '--memori-text-color': (_x = integrationConfig.textColor) !== null && _x !== void 0 ? _x : '#000' }
|
|
1454
1483
|
: {}),
|
|
1455
1484
|
...((integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.buttonBgColor)
|
|
1456
1485
|
? {
|
|
@@ -1474,12 +1503,12 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1474
1503
|
? {
|
|
1475
1504
|
'--memori-inner-bg': `rgba(${integrationConfig.innerBgColor === 'dark'
|
|
1476
1505
|
? '0, 0, 0'
|
|
1477
|
-
: '255, 255, 255'}, ${(
|
|
1506
|
+
: '255, 255, 255'}, ${(_y = integrationConfig.innerBgAlpha) !== null && _y !== void 0 ? _y : 0.4})`,
|
|
1478
1507
|
'--memori-inner-content-pad': '1.5rem',
|
|
1479
1508
|
'--memori-nav-bg-image': 'none',
|
|
1480
1509
|
'--memori-nav-bg': `rgba(${integrationConfig.innerBgColor === 'dark'
|
|
1481
1510
|
? '0, 0, 0'
|
|
1482
|
-
: '255, 255, 255'}, ${(
|
|
1511
|
+
: '255, 255, 255'}, ${(_z = integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.innerBgAlpha) !== null && _z !== void 0 ? _z : 0.4})`,
|
|
1483
1512
|
}
|
|
1484
1513
|
: {
|
|
1485
1514
|
'--memori-inner-content-pad': '0px',
|
|
@@ -1578,7 +1607,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1578
1607
|
};
|
|
1579
1608
|
}, [sessionId, userLang, disableTextEnteredEvents]);
|
|
1580
1609
|
const onClickStart = useCallback(async (session, initialSessionExpired = false, chatLog, targetSessionID) => {
|
|
1581
|
-
var _a, _b, _c, _d, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t
|
|
1610
|
+
var _a, _b, _c, _d, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
|
1582
1611
|
const sessionID = chatLog ? undefined : (session === null || session === void 0 ? void 0 : session.sessionID) || sessionId;
|
|
1583
1612
|
const dialogState = chatLog
|
|
1584
1613
|
? undefined
|
|
@@ -1639,8 +1668,8 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1639
1668
|
birthDate: birth,
|
|
1640
1669
|
additionalInfo: {
|
|
1641
1670
|
...(additionalInfo || {}),
|
|
1642
|
-
loginToken: (
|
|
1643
|
-
language: ((
|
|
1671
|
+
loginToken: resolveLoginToken(),
|
|
1672
|
+
language: ((_h = userLang !== null && userLang !== void 0 ? userLang : (_g = (_f = memori.culture) === null || _f === void 0 ? void 0 : _f.split('-')) === null || _g === void 0 ? void 0 : _g[0]) !== null && _h !== void 0 ? _h : 'IT').toLowerCase(),
|
|
1644
1673
|
timeZoneOffset: new Date().getTimezoneOffset().toString(),
|
|
1645
1674
|
},
|
|
1646
1675
|
});
|
|
@@ -1682,7 +1711,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1682
1711
|
};
|
|
1683
1712
|
}));
|
|
1684
1713
|
}
|
|
1685
|
-
catch (
|
|
1714
|
+
catch (_u) {
|
|
1686
1715
|
}
|
|
1687
1716
|
}
|
|
1688
1717
|
setHistory(translatedMessages);
|
|
@@ -1729,11 +1758,11 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1729
1758
|
throw new Error('No session');
|
|
1730
1759
|
}
|
|
1731
1760
|
}
|
|
1732
|
-
catch (
|
|
1761
|
+
catch (_v) {
|
|
1733
1762
|
reopenSession(true, memori === null || memori === void 0 ? void 0 : memori.secretToken, undefined, personification.tag, personification.pin, {
|
|
1734
1763
|
LANG: userLang,
|
|
1735
|
-
PATHNAME: (
|
|
1736
|
-
ROUTE: ((
|
|
1764
|
+
PATHNAME: (_j = window.location.pathname) === null || _j === void 0 ? void 0 : _j.toUpperCase(),
|
|
1765
|
+
ROUTE: ((_m = (_l = (_k = window.location.pathname) === null || _k === void 0 ? void 0 : _k.split('/')) === null || _l === void 0 ? void 0 : _l.pop()) === null || _m === void 0 ? void 0 : _m.toUpperCase()) ||
|
|
1737
1766
|
'',
|
|
1738
1767
|
...(initialContextVars || {}),
|
|
1739
1768
|
}, initialQuestion, birth).then(() => {
|
|
@@ -1760,8 +1789,8 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1760
1789
|
catch (e) {
|
|
1761
1790
|
reopenSession(true, memori === null || memori === void 0 ? void 0 : memori.secretToken, undefined, undefined, undefined, {
|
|
1762
1791
|
LANG: userLang,
|
|
1763
|
-
PATHNAME: (
|
|
1764
|
-
ROUTE: ((
|
|
1792
|
+
PATHNAME: (_o = window.location.pathname) === null || _o === void 0 ? void 0 : _o.toUpperCase(),
|
|
1793
|
+
ROUTE: ((_r = (_q = (_p = window.location.pathname) === null || _p === void 0 ? void 0 : _p.split('/')) === null || _q === void 0 ? void 0 : _q.pop()) === null || _r === void 0 ? void 0 : _r.toUpperCase()) ||
|
|
1765
1794
|
'',
|
|
1766
1795
|
...(initialContextVars || {}),
|
|
1767
1796
|
}, initialQuestion, birth).then(() => {
|
|
@@ -1773,7 +1802,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1773
1802
|
else {
|
|
1774
1803
|
try {
|
|
1775
1804
|
const { chatLogs } = await getSessionChatLogs(sessionID, sessionID);
|
|
1776
|
-
const messages = (
|
|
1805
|
+
const messages = (_s = chatLogs === null || chatLogs === void 0 ? void 0 : chatLogs[0]) === null || _s === void 0 ? void 0 : _s.lines.map((l, i) => {
|
|
1777
1806
|
var _a, _b;
|
|
1778
1807
|
return ({
|
|
1779
1808
|
text: l.text,
|
|
@@ -1798,12 +1827,12 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1798
1827
|
text: (await getTranslation(m.text, userLang, language, baseUrl)).text,
|
|
1799
1828
|
})));
|
|
1800
1829
|
}
|
|
1801
|
-
catch (
|
|
1830
|
+
catch (_w) {
|
|
1802
1831
|
}
|
|
1803
1832
|
}
|
|
1804
1833
|
setHistory(translatedMessages);
|
|
1805
1834
|
}
|
|
1806
|
-
catch (
|
|
1835
|
+
catch (_x) {
|
|
1807
1836
|
}
|
|
1808
1837
|
if ((!!(translatedMessages === null || translatedMessages === void 0 ? void 0 : translatedMessages.length) && translatedMessages.length > 1) ||
|
|
1809
1838
|
!initialQuestion) {
|
|
@@ -1819,7 +1848,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1819
1848
|
sessionId: sessionID,
|
|
1820
1849
|
text: initialQuestion,
|
|
1821
1850
|
...(memori.needsDateTime && {
|
|
1822
|
-
dateUTC: (
|
|
1851
|
+
dateUTC: (_t = DateTime.utc().toISO()) !== null && _t !== void 0 ? _t : undefined,
|
|
1823
1852
|
}),
|
|
1824
1853
|
...(placeSpec !== undefined && { place: placeSpec }),
|
|
1825
1854
|
});
|
|
@@ -1885,27 +1914,35 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1885
1914
|
hasEnoughCredits,
|
|
1886
1915
|
]);
|
|
1887
1916
|
useEffect(() => {
|
|
1917
|
+
var _a;
|
|
1888
1918
|
const targetNode = document.querySelector(`memori-client[memoriname="${memori.name}"]`) ||
|
|
1889
1919
|
document.querySelector(`memori-client[memoriid="${memori.memoriID}"]`) ||
|
|
1890
1920
|
document.querySelector('memori-client');
|
|
1891
1921
|
if (!targetNode) {
|
|
1892
1922
|
return;
|
|
1893
1923
|
}
|
|
1924
|
+
const propsToken = (_a = additionalInfo === null || additionalInfo === void 0 ? void 0 : additionalInfo.loginToken) !== null && _a !== void 0 ? _a : authToken;
|
|
1925
|
+
const initialDomToken = targetNode.getAttribute('authtoken') || undefined;
|
|
1926
|
+
if (initialDomToken && !propsToken) {
|
|
1927
|
+
setLoginToken(initialDomToken);
|
|
1928
|
+
userTokenRef.current = initialDomToken;
|
|
1929
|
+
}
|
|
1930
|
+
const applyAuthTokenFromElement = (element) => {
|
|
1931
|
+
var _a;
|
|
1932
|
+
const clientNode = element.nodeName === 'MEMORI-CLIENT'
|
|
1933
|
+
? element
|
|
1934
|
+
: (_a = element.closest('memori-client')) !== null && _a !== void 0 ? _a : element.parentElement;
|
|
1935
|
+
const token = (clientNode === null || clientNode === void 0 ? void 0 : clientNode.getAttribute('authtoken')) || undefined;
|
|
1936
|
+
setLoginToken(token);
|
|
1937
|
+
userTokenRef.current = token;
|
|
1938
|
+
};
|
|
1894
1939
|
const config = { attributes: true, childList: false, subtree: false };
|
|
1895
|
-
const callback =
|
|
1896
|
-
var _a
|
|
1940
|
+
const callback = mutationList => {
|
|
1941
|
+
var _a;
|
|
1897
1942
|
for (const mutation of mutationList) {
|
|
1898
1943
|
if (mutation.type === 'attributes' &&
|
|
1899
1944
|
((_a = mutation.attributeName) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === 'authtoken') {
|
|
1900
|
-
|
|
1901
|
-
setLoginToken(mutation.target.getAttribute('authtoken') || undefined);
|
|
1902
|
-
userToken = mutation.target.getAttribute('authtoken') || undefined;
|
|
1903
|
-
}
|
|
1904
|
-
else {
|
|
1905
|
-
setLoginToken(((_c = (_b = mutation.target) === null || _b === void 0 ? void 0 : _b.parentElement) === null || _c === void 0 ? void 0 : _c.getAttribute('authtoken')) ||
|
|
1906
|
-
undefined);
|
|
1907
|
-
userToken = mutation.target.getAttribute('authtoken') || undefined;
|
|
1908
|
-
}
|
|
1945
|
+
applyAuthTokenFromElement(mutation.target);
|
|
1909
1946
|
}
|
|
1910
1947
|
}
|
|
1911
1948
|
};
|
|
@@ -1914,7 +1951,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1914
1951
|
return () => {
|
|
1915
1952
|
observer.disconnect();
|
|
1916
1953
|
};
|
|
1917
|
-
}, []);
|
|
1954
|
+
}, [memori.name, memori.memoriID, additionalInfo === null || additionalInfo === void 0 ? void 0 : additionalInfo.loginToken, authToken]);
|
|
1918
1955
|
const [experts, setExperts] = useState();
|
|
1919
1956
|
const fetchExperts = useCallback(async () => {
|
|
1920
1957
|
if (!sessionId || !(memori === null || memori === void 0 ? void 0 : memori.enableBoardOfExperts))
|
|
@@ -2012,16 +2049,16 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
2012
2049
|
? selectedLayout !== 'TOTEM' && selectedLayout !== 'WEBSITE_ASSISTANT'
|
|
2013
2050
|
: !showOnlyLastMessages;
|
|
2014
2051
|
const canShowLoginButton = !(tenant === null || tenant === void 0 ? void 0 : tenant.ssoLogin) &&
|
|
2015
|
-
((
|
|
2052
|
+
((_0 = showLogin !== null && showLogin !== void 0 ? showLogin : integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.showLogin) !== null && _0 !== void 0 ? _0 : memori.requireLoginToken);
|
|
2016
2053
|
const headerProps = {
|
|
2017
2054
|
memori: {
|
|
2018
2055
|
...memori,
|
|
2019
|
-
ownerUserID: (
|
|
2056
|
+
ownerUserID: (_2 = (_1 = memori.ownerUserID) !== null && _1 !== void 0 ? _1 : ownerUserID) !== null && _2 !== void 0 ? _2 : undefined,
|
|
2020
2057
|
},
|
|
2021
2058
|
apiClient: client,
|
|
2022
2059
|
tenant,
|
|
2023
2060
|
history,
|
|
2024
|
-
showShare: (
|
|
2061
|
+
showShare: (_3 = showShare !== null && showShare !== void 0 ? showShare : integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.showShare) !== null && _3 !== void 0 ? _3 : true,
|
|
2025
2062
|
position,
|
|
2026
2063
|
layout: selectedLayout,
|
|
2027
2064
|
additionalSettings,
|
|
@@ -2029,18 +2066,18 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
2029
2066
|
setShowSettingsDrawer,
|
|
2030
2067
|
setShowKnownFactsDrawer,
|
|
2031
2068
|
setShowExpertsDrawer,
|
|
2032
|
-
enableAudio: (
|
|
2069
|
+
enableAudio: (_4 = enableAudio !== null && enableAudio !== void 0 ? enableAudio : integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.enableAudio) !== null && _4 !== void 0 ? _4 : true,
|
|
2033
2070
|
speakerMuted: speakerMuted !== null && speakerMuted !== void 0 ? speakerMuted : false,
|
|
2034
2071
|
setSpeakerMuted: (mute) => {
|
|
2035
2072
|
toggleMute(mute);
|
|
2036
2073
|
},
|
|
2037
2074
|
setShowChatHistoryDrawer,
|
|
2038
|
-
showSettings: (
|
|
2039
|
-
showChatHistory: (
|
|
2075
|
+
showSettings: (_5 = showSettings !== null && showSettings !== void 0 ? showSettings : integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.showSettings) !== null && _5 !== void 0 ? _5 : true,
|
|
2076
|
+
showChatHistory: (_6 = showChatHistory !== null && showChatHistory !== void 0 ? showChatHistory : integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.showChatHistory) !== null && _6 !== void 0 ? _6 : true,
|
|
2040
2077
|
showMessageConsumption: enableMessageConsumption,
|
|
2041
2078
|
hasUserActivatedSpeak,
|
|
2042
2079
|
showReload: selectedLayout === 'TOTEM',
|
|
2043
|
-
showClear: (
|
|
2080
|
+
showClear: (_7 = showClear !== null && showClear !== void 0 ? showClear : integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.showClear) !== null && _7 !== void 0 ? _7 : false,
|
|
2044
2081
|
clearHistory: () => setHistory(h => h.slice(-1)),
|
|
2045
2082
|
showLogin: canShowLoginButton,
|
|
2046
2083
|
setShowLoginDrawer,
|
|
@@ -2055,7 +2092,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
2055
2092
|
setShowLoginDrawer(false);
|
|
2056
2093
|
setUser(undefined);
|
|
2057
2094
|
setLoginToken(undefined);
|
|
2058
|
-
|
|
2095
|
+
userTokenRef.current = undefined;
|
|
2059
2096
|
removeLocalConfig('loginToken');
|
|
2060
2097
|
});
|
|
2061
2098
|
},
|
|
@@ -2071,7 +2108,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
2071
2108
|
hasUserActivatedSpeak,
|
|
2072
2109
|
isPlayingAudio: isPlayingAudio &&
|
|
2073
2110
|
!speakerMuted &&
|
|
2074
|
-
((
|
|
2111
|
+
((_8 = enableAudio !== null && enableAudio !== void 0 ? enableAudio : integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.enableAudio) !== null && _8 !== void 0 ? _8 : true),
|
|
2075
2112
|
loading: !!memoriTyping,
|
|
2076
2113
|
baseUrl,
|
|
2077
2114
|
apiUrl: client.constants.BACKEND_URL,
|
|
@@ -2108,7 +2145,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
2108
2145
|
tenant,
|
|
2109
2146
|
translateTo: isMultilanguageEnabled &&
|
|
2110
2147
|
userLang.toUpperCase() !==
|
|
2111
|
-
((
|
|
2148
|
+
((_13 = ((_12 = (_11 = (_10 = (_9 = memori.culture) === null || _9 === void 0 ? void 0 : _9.split('-')) === null || _10 === void 0 ? void 0 : _10[0]) !== null && _11 !== void 0 ? _11 : i18n.language) !== null && _12 !== void 0 ? _12 : 'IT')) === null || _13 === void 0 ? void 0 : _13.toUpperCase())
|
|
2112
2149
|
? userLang
|
|
2113
2150
|
: undefined,
|
|
2114
2151
|
baseUrl,
|
|
@@ -2116,9 +2153,9 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
2116
2153
|
layout,
|
|
2117
2154
|
memoriTyping,
|
|
2118
2155
|
typingText,
|
|
2119
|
-
showTypingText: (
|
|
2156
|
+
showTypingText: (_14 = showTypingText !== null && showTypingText !== void 0 ? showTypingText : integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.showTypingText) !== null && _14 !== void 0 ? _14 : false,
|
|
2120
2157
|
history: showFullHistory ? history : history.slice(-2),
|
|
2121
|
-
authToken: (
|
|
2158
|
+
authToken: resolveLoginToken(),
|
|
2122
2159
|
dialogState: currentDialogState,
|
|
2123
2160
|
pushMessage,
|
|
2124
2161
|
simulateUserPrompt,
|
|
@@ -2291,7 +2328,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
2291
2328
|
setShowLoginDrawer(false);
|
|
2292
2329
|
setUser(user);
|
|
2293
2330
|
setLoginToken(token);
|
|
2294
|
-
|
|
2331
|
+
userTokenRef.current = token;
|
|
2295
2332
|
setLocalConfig('loginToken', token);
|
|
2296
2333
|
if ((state === null || state === void 0 ? void 0 : state.sessionID) &&
|
|
2297
2334
|
state.sessionID !== sessionId &&
|
|
@@ -2322,7 +2359,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
2322
2359
|
setShowLoginDrawer(false);
|
|
2323
2360
|
setUser(undefined);
|
|
2324
2361
|
setLoginToken(undefined);
|
|
2325
|
-
|
|
2362
|
+
userTokenRef.current = undefined;
|
|
2326
2363
|
removeLocalConfig('loginToken');
|
|
2327
2364
|
});
|
|
2328
2365
|
} }))] }));
|