@memori.ai/memori-react 8.40.0 → 8.40.1
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 +7 -0
- package/dist/components/MemoriWidget/MemoriWidget.js +93 -73
- package/dist/components/MemoriWidget/MemoriWidget.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/esm/components/MemoriWidget/MemoriWidget.js +96 -74
- package/esm/components/MemoriWidget/MemoriWidget.js.map +1 -1
- package/esm/version.d.ts +1 -1
- package/esm/version.js +1 -1
- package/package.json +1 -1
- package/src/components/MemoriWidget/MemoriWidget.tsx +68 -41
- package/src/components/layouts/layouts.stories.tsx +1 -1
- package/src/version.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
+
## [8.40.1](https://github.com/memori-ai/memori-react/compare/v8.40.0...v8.40.1) (2026-06-17)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* add session management improvements in MemoriWidget ([a055776](https://github.com/memori-ai/memori-react/commit/a05577666d53c5ee8becf51954f6abdf9f2bd864))
|
|
9
|
+
|
|
3
10
|
## [8.40.0](https://github.com/memori-ai/memori-react/compare/v8.39.0...v8.40.0) (2026-06-17)
|
|
4
11
|
|
|
5
12
|
|
|
@@ -208,6 +208,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
208
208
|
}, [loginToken, user === null || user === void 0 ? void 0 : user.userID]);
|
|
209
209
|
const [showLoginDrawer, setShowLoginDrawer] = (0, react_1.useState)(false);
|
|
210
210
|
const [clickedStart, setClickedStart] = (0, react_1.useState)(false);
|
|
211
|
+
const sessionStartingRef = (0, react_1.useRef)(false);
|
|
211
212
|
const language = ((_d = (_c = (_b = memori.culture) === null || _b === void 0 ? void 0 : _b.split('-')) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.toUpperCase()) ||
|
|
212
213
|
((_j = (_h = (_g = (_f = memoriConfigs === null || memoriConfigs === void 0 ? void 0 : memoriConfigs.find(c => c.memoriConfigID === memori.memoriConfigurationID)) === null || _f === void 0 ? void 0 : _f.culture) === null || _g === void 0 ? void 0 : _g.split('-')) === null || _h === void 0 ? void 0 : _h[0]) === null || _j === void 0 ? void 0 : _j.toUpperCase());
|
|
213
214
|
const integrationConfig = (integration === null || integration === void 0 ? void 0 : integration.customData)
|
|
@@ -1046,6 +1047,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1046
1047
|
return () => {
|
|
1047
1048
|
setHasUserActivatedSpeak(false);
|
|
1048
1049
|
setClickedStart(false);
|
|
1050
|
+
sessionStartingRef.current = false;
|
|
1049
1051
|
clearInteractionTimeout();
|
|
1050
1052
|
timeoutRef.current = undefined;
|
|
1051
1053
|
};
|
|
@@ -1634,6 +1636,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1634
1636
|
if (!sessionID && !!minAge && !birth) {
|
|
1635
1637
|
setShowAgeVerification(true);
|
|
1636
1638
|
setClickedStart(false);
|
|
1639
|
+
return;
|
|
1637
1640
|
}
|
|
1638
1641
|
else if (!sessionID &&
|
|
1639
1642
|
memori.privacyType !== 'PUBLIC' &&
|
|
@@ -1645,82 +1648,95 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1645
1648
|
return;
|
|
1646
1649
|
}
|
|
1647
1650
|
else if (!sessionID || initialSessionExpired) {
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
:
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
initial: i === 0,
|
|
1692
|
-
});
|
|
1693
|
-
});
|
|
1694
|
-
translatedMessages = messages !== null && messages !== void 0 ? messages : [];
|
|
1695
|
-
if (language.toUpperCase() !== userLang.toUpperCase() &&
|
|
1696
|
-
isMultilanguageEnabled) {
|
|
1697
|
-
try {
|
|
1698
|
-
translatedMessages = await Promise.all(messages.map(async (m) => {
|
|
1699
|
-
if ('originalText' in m && m.originalText) {
|
|
1700
|
-
return m;
|
|
1701
|
-
}
|
|
1702
|
-
return {
|
|
1651
|
+
if (sessionStartingRef.current) {
|
|
1652
|
+
return;
|
|
1653
|
+
}
|
|
1654
|
+
sessionStartingRef.current = true;
|
|
1655
|
+
try {
|
|
1656
|
+
const session = await fetchSession({
|
|
1657
|
+
memoriID: memori.engineMemoriID,
|
|
1658
|
+
password: secret || memoriPwd || memori.secretToken,
|
|
1659
|
+
tag: personification === null || personification === void 0 ? void 0 : personification.tag,
|
|
1660
|
+
pin: personification === null || personification === void 0 ? void 0 : personification.pin,
|
|
1661
|
+
continueFromChatLogID: chatLog === null || chatLog === void 0 ? void 0 : chatLog.chatLogID,
|
|
1662
|
+
initialContextVars: {
|
|
1663
|
+
LANG: userLang,
|
|
1664
|
+
PATHNAME: (_a = window.location.pathname) === null || _a === void 0 ? void 0 : _a.toUpperCase(),
|
|
1665
|
+
ROUTE: ((_d = (_c = (_b = window.location.pathname) === null || _b === void 0 ? void 0 : _b.split('/')) === null || _c === void 0 ? void 0 : _c.pop()) === null || _d === void 0 ? void 0 : _d.toUpperCase()) ||
|
|
1666
|
+
'',
|
|
1667
|
+
...((!chatLog
|
|
1668
|
+
? initialContextVars
|
|
1669
|
+
: chatLog.lines[chatLog.lines.length - 1].contextVars) || {}),
|
|
1670
|
+
},
|
|
1671
|
+
initialQuestion: chatLog ? undefined : initialQuestion,
|
|
1672
|
+
birthDate: birth,
|
|
1673
|
+
additionalInfo: {
|
|
1674
|
+
...(additionalInfo || {}),
|
|
1675
|
+
loginToken: (_g = (_f = userToken !== null && userToken !== void 0 ? userToken : loginToken) !== null && _f !== void 0 ? _f : additionalInfo === null || additionalInfo === void 0 ? void 0 : additionalInfo.loginToken) !== null && _g !== void 0 ? _g : authToken,
|
|
1676
|
+
language: ((_k = userLang !== null && userLang !== void 0 ? userLang : (_j = (_h = memori.culture) === null || _h === void 0 ? void 0 : _h.split('-')) === null || _j === void 0 ? void 0 : _j[0]) !== null && _k !== void 0 ? _k : 'IT').toLowerCase(),
|
|
1677
|
+
timeZoneOffset: new Date().getTimezoneOffset().toString(),
|
|
1678
|
+
},
|
|
1679
|
+
});
|
|
1680
|
+
if (session === null || session === void 0 ? void 0 : session.dialogState) {
|
|
1681
|
+
if (!chatLog) {
|
|
1682
|
+
setHistory([]);
|
|
1683
|
+
await translateAndSpeak(session.dialogState, userLang);
|
|
1684
|
+
setHasUserActivatedSpeak(true);
|
|
1685
|
+
setClickedStart(false);
|
|
1686
|
+
}
|
|
1687
|
+
else {
|
|
1688
|
+
const messages = chatLog.lines.map((l, i) => {
|
|
1689
|
+
var _a, _b;
|
|
1690
|
+
return ({
|
|
1691
|
+
text: l.text,
|
|
1692
|
+
media: (_b = (_a = l.media) === null || _a === void 0 ? void 0 : _a.filter(m => constants_1.allowedMediaTypes.includes(m.mimeType))) === null || _b === void 0 ? void 0 : _b.map(m => ({
|
|
1693
|
+
mediumID: `${i}-${m.mimeType}`,
|
|
1703
1694
|
...m,
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1695
|
+
})),
|
|
1696
|
+
fromUser: l.inbound,
|
|
1697
|
+
llmUsage: l.llmUsage,
|
|
1698
|
+
timestamp: l.timestamp,
|
|
1699
|
+
emitter: l.emitter,
|
|
1700
|
+
initial: i === 0,
|
|
1701
|
+
});
|
|
1702
|
+
});
|
|
1703
|
+
translatedMessages = messages !== null && messages !== void 0 ? messages : [];
|
|
1704
|
+
if (language.toUpperCase() !== userLang.toUpperCase() &&
|
|
1705
|
+
isMultilanguageEnabled) {
|
|
1706
|
+
try {
|
|
1707
|
+
translatedMessages = await Promise.all(messages.map(async (m) => {
|
|
1708
|
+
if ('originalText' in m && m.originalText) {
|
|
1709
|
+
return m;
|
|
1710
|
+
}
|
|
1711
|
+
return {
|
|
1712
|
+
...m,
|
|
1713
|
+
originalText: m.text,
|
|
1714
|
+
text: (await (0, translations_1.getTranslation)(m.text, userLang, language, baseUrl)).text,
|
|
1715
|
+
};
|
|
1716
|
+
}));
|
|
1717
|
+
}
|
|
1718
|
+
catch (e) {
|
|
1719
|
+
console.error('[onClickStart] Error translating messages:', e);
|
|
1720
|
+
}
|
|
1711
1721
|
}
|
|
1722
|
+
setHistory(translatedMessages);
|
|
1723
|
+
translateDialogState(session.dialogState, userLang, undefined, true).finally(() => {
|
|
1724
|
+
setHasUserActivatedSpeak(true);
|
|
1725
|
+
setClickedStart(false);
|
|
1726
|
+
});
|
|
1712
1727
|
}
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1728
|
+
}
|
|
1729
|
+
else if ((session === null || session === void 0 ? void 0 : session.resultCode) === 0) {
|
|
1730
|
+
sessionStartingRef.current = false;
|
|
1731
|
+
await onClickStart(session || undefined);
|
|
1732
|
+
}
|
|
1733
|
+
else {
|
|
1734
|
+
setLoading(false);
|
|
1735
|
+
setClickedStart(false);
|
|
1717
1736
|
}
|
|
1718
1737
|
}
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
}
|
|
1722
|
-
else {
|
|
1723
|
-
setLoading(false);
|
|
1738
|
+
finally {
|
|
1739
|
+
sessionStartingRef.current = false;
|
|
1724
1740
|
}
|
|
1725
1741
|
return;
|
|
1726
1742
|
}
|
|
@@ -1757,6 +1773,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1757
1773
|
...(initialContextVars || {}),
|
|
1758
1774
|
}, initialQuestion, birth).then(() => {
|
|
1759
1775
|
setHasUserActivatedSpeak(true);
|
|
1776
|
+
setClickedStart(false);
|
|
1760
1777
|
});
|
|
1761
1778
|
}
|
|
1762
1779
|
}
|
|
@@ -1896,10 +1913,13 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1896
1913
|
}
|
|
1897
1914
|
}, [memoriPwd, memori, memoriTokens, birthDate, sessionId, userLang, position]);
|
|
1898
1915
|
(0, react_1.useEffect)(() => {
|
|
1899
|
-
if (!clickedStart &&
|
|
1916
|
+
if (!clickedStart &&
|
|
1917
|
+
!sessionStartingRef.current &&
|
|
1918
|
+
autoStart &&
|
|
1919
|
+
selectedLayout !== 'HIDDEN_CHAT') {
|
|
1900
1920
|
onClickStart();
|
|
1901
1921
|
}
|
|
1902
|
-
}, [clickedStart, autoStart, selectedLayout]);
|
|
1922
|
+
}, [clickedStart, autoStart, selectedLayout, sessionId]);
|
|
1903
1923
|
(0, react_1.useEffect)(() => {
|
|
1904
1924
|
const targetNode = document.querySelector(`memori-client[memoriname="${memori.name}"]`) ||
|
|
1905
1925
|
document.querySelector(`memori-client[memoriid="${memori.memoriID}"]`) ||
|