@memori.ai/memori-react 2.11.0 → 2.12.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 +11 -0
- package/dist/components/Chat/Chat.d.ts +2 -2
- package/dist/components/Chat/Chat.js +1 -1
- package/dist/components/Chat/Chat.js.map +1 -1
- package/dist/components/MediaWidget/MediaItemWidget.d.ts +2 -2
- package/dist/components/MediaWidget/MediaItemWidget.js +1 -13
- package/dist/components/MediaWidget/MediaItemWidget.js.map +1 -1
- package/dist/components/MediaWidget/MediaWidget.d.ts +2 -2
- package/dist/components/MediaWidget/MediaWidget.js +1 -1
- package/dist/components/MediaWidget/MediaWidget.js.map +1 -1
- package/dist/components/MemoriWidget/MemoriWidget.d.ts +2 -2
- package/dist/components/MemoriWidget/MemoriWidget.js +38 -2
- package/dist/components/MemoriWidget/MemoriWidget.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/esm/components/Chat/Chat.d.ts +2 -2
- package/esm/components/Chat/Chat.js +2 -2
- package/esm/components/Chat/Chat.js.map +1 -1
- package/esm/components/MediaWidget/MediaItemWidget.d.ts +2 -2
- package/esm/components/MediaWidget/MediaItemWidget.js +2 -14
- package/esm/components/MediaWidget/MediaItemWidget.js.map +1 -1
- package/esm/components/MediaWidget/MediaWidget.d.ts +2 -2
- package/esm/components/MediaWidget/MediaWidget.js +2 -2
- package/esm/components/MediaWidget/MediaWidget.js.map +1 -1
- package/esm/components/MemoriWidget/MemoriWidget.d.ts +2 -2
- package/esm/components/MemoriWidget/MemoriWidget.js +39 -3
- package/esm/components/MemoriWidget/MemoriWidget.js.map +1 -1
- package/esm/index.js +1 -1
- package/esm/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Chat/Chat.tsx +2 -2
- package/src/components/MediaWidget/MediaItemWidget.tsx +2 -17
- package/src/components/MediaWidget/MediaWidget.tsx +2 -2
- package/src/components/MemoriWidget/MemoriWidget.tsx +45 -2
- package/src/components/layouts/layouts.stories.tsx +1 -1
- package/src/index.tsx +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useEffect } from 'react';
|
|
1
|
+
import React, { useEffect, memo } from 'react';
|
|
2
2
|
import cx from 'classnames';
|
|
3
3
|
import {
|
|
4
4
|
DialogState,
|
|
@@ -336,4 +336,4 @@ const Chat: React.FC<Props> = ({
|
|
|
336
336
|
);
|
|
337
337
|
};
|
|
338
338
|
|
|
339
|
-
export default Chat;
|
|
339
|
+
export default memo(Chat);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Medium } from '@memori.ai/memori-api-client/dist/types';
|
|
2
|
-
import React, { useCallback, useEffect, useState } from 'react';
|
|
2
|
+
import React, { useCallback, useEffect, useState, memo } from 'react';
|
|
3
3
|
import { getResourceUrl } from '../../helpers/media';
|
|
4
4
|
import { getTranslation } from '../../helpers/translations';
|
|
5
5
|
import { prismSyntaxLangs } from '../../helpers/constants';
|
|
@@ -285,21 +285,6 @@ const MediaItemWidget: React.FC<Props> = ({
|
|
|
285
285
|
if (translateTo) translateMediaCaptions();
|
|
286
286
|
}, [translateTo, translateMediaCaptions]);
|
|
287
287
|
|
|
288
|
-
useEffect(() => {
|
|
289
|
-
let executableScripts = items.filter(
|
|
290
|
-
m => m.mimeType === 'text/javascript' && !!m.properties?.executable
|
|
291
|
-
);
|
|
292
|
-
executableScripts.forEach(s => {
|
|
293
|
-
try {
|
|
294
|
-
// eslint-disable-next-line no-new-func
|
|
295
|
-
new Function(s.content ?? '')();
|
|
296
|
-
} catch (e) {
|
|
297
|
-
console.error(e);
|
|
298
|
-
}
|
|
299
|
-
});
|
|
300
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
301
|
-
}, []);
|
|
302
|
-
|
|
303
288
|
return (
|
|
304
289
|
<Transition appear show as="div" className="memori-media-items">
|
|
305
290
|
<div className="memori-media-items--grid">
|
|
@@ -407,4 +392,4 @@ const MediaItemWidget: React.FC<Props> = ({
|
|
|
407
392
|
);
|
|
408
393
|
};
|
|
409
394
|
|
|
410
|
-
export default MediaItemWidget;
|
|
395
|
+
export default memo(MediaItemWidget);
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
Medium,
|
|
3
3
|
TranslatedHint,
|
|
4
4
|
} from '@memori.ai/memori-api-client/dist/types';
|
|
5
|
-
import React, { useEffect, useState } from 'react';
|
|
5
|
+
import React, { useEffect, useState, memo } from 'react';
|
|
6
6
|
import Button from '../ui/Button';
|
|
7
7
|
import LinkItemWidget from './LinkItemWidget';
|
|
8
8
|
import MediaItemWidget, { Props as MediaItemProps } from './MediaItemWidget';
|
|
@@ -103,4 +103,4 @@ const MediaWidget: React.FC<Props> = ({
|
|
|
103
103
|
);
|
|
104
104
|
};
|
|
105
105
|
|
|
106
|
-
export default MediaWidget;
|
|
106
|
+
export default memo(MediaWidget);
|
|
@@ -29,6 +29,7 @@ import React, {
|
|
|
29
29
|
useCallback,
|
|
30
30
|
CSSProperties,
|
|
31
31
|
useRef,
|
|
32
|
+
memo,
|
|
32
33
|
} from 'react';
|
|
33
34
|
import { useTranslation } from 'react-i18next';
|
|
34
35
|
import memoriApiClient from '@memori.ai/memori-api-client';
|
|
@@ -400,7 +401,17 @@ const MemoriWidget = ({
|
|
|
400
401
|
const [listening, setListening] = useState(false);
|
|
401
402
|
const [history, setHistory] = useState<Message[]>([]);
|
|
402
403
|
const pushMessage = (message: Message) => {
|
|
403
|
-
setHistory(history => [
|
|
404
|
+
setHistory(history => [
|
|
405
|
+
...history,
|
|
406
|
+
{
|
|
407
|
+
...message,
|
|
408
|
+
media:
|
|
409
|
+
message.media?.filter(
|
|
410
|
+
m =>
|
|
411
|
+
!(m.mimeType === 'text/javascript' && !!m.properties?.executable)
|
|
412
|
+
) ?? [],
|
|
413
|
+
},
|
|
414
|
+
]);
|
|
404
415
|
};
|
|
405
416
|
const sendMessage = async (
|
|
406
417
|
text: string,
|
|
@@ -654,6 +665,38 @@ const MemoriWidget = ({
|
|
|
654
665
|
if (onStateChange) {
|
|
655
666
|
onStateChange(state);
|
|
656
667
|
}
|
|
668
|
+
|
|
669
|
+
const executableSnippets = state?.media?.filter(
|
|
670
|
+
m => m.mimeType === 'text/javascript' && !!m.properties?.executable
|
|
671
|
+
);
|
|
672
|
+
executableSnippets?.forEach(s => {
|
|
673
|
+
try {
|
|
674
|
+
setTimeout(() => {
|
|
675
|
+
console.log('snippet', s);
|
|
676
|
+
// eslint-disable-next-line no-new-func
|
|
677
|
+
new Function(s.content ?? '')();
|
|
678
|
+
|
|
679
|
+
setTimeout(() => {
|
|
680
|
+
if (document.body.classList.contains('chat-focused')) {
|
|
681
|
+
document.querySelector('.ant-tabs-nav')?.scrollIntoView();
|
|
682
|
+
document
|
|
683
|
+
.querySelector('.memori-chat--content')
|
|
684
|
+
?.scrollTo(
|
|
685
|
+
0,
|
|
686
|
+
document.querySelector('.memori-chat--content')
|
|
687
|
+
?.scrollHeight ?? 0
|
|
688
|
+
);
|
|
689
|
+
} else {
|
|
690
|
+
document.querySelector('#end-messages-ref')?.scrollIntoView({
|
|
691
|
+
behavior: 'smooth',
|
|
692
|
+
});
|
|
693
|
+
}
|
|
694
|
+
}, 400);
|
|
695
|
+
}, 3000);
|
|
696
|
+
} catch (e) {
|
|
697
|
+
console.error(e);
|
|
698
|
+
}
|
|
699
|
+
});
|
|
657
700
|
};
|
|
658
701
|
const fetchSession = async (
|
|
659
702
|
params: OpenSession
|
|
@@ -2704,4 +2747,4 @@ const MemoriWidget = ({
|
|
|
2704
2747
|
);
|
|
2705
2748
|
};
|
|
2706
2749
|
|
|
2707
|
-
export default MemoriWidget;
|
|
2750
|
+
export default memo(MemoriWidget);
|
package/src/index.tsx
CHANGED
|
@@ -248,7 +248,7 @@ Memori.propTypes = {
|
|
|
248
248
|
showShare: PropTypes.bool,
|
|
249
249
|
showSettings: PropTypes.bool,
|
|
250
250
|
showInstruct: PropTypes.bool,
|
|
251
|
-
layout: PropTypes.oneOf(['DEFAULT', 'FULLPAGE', 'TOTEM']),
|
|
251
|
+
layout: PropTypes.oneOf(['DEFAULT', 'FULLPAGE', 'TOTEM', 'CHAT']),
|
|
252
252
|
height: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
253
253
|
baseURL: PropTypes.string,
|
|
254
254
|
apiURL: PropTypes.string,
|