@memori.ai/memori-react 7.17.0 → 7.17.2

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.
@@ -139,10 +139,25 @@ const Header: React.FC<Props> = ({
139
139
  icon={fullScreen ? <FullscreenExit /> : <Fullscreen />}
140
140
  onClick={() => {
141
141
  if (!document.fullscreenElement) {
142
- document.documentElement.requestFullscreen();
142
+ const memoriWidget = document.querySelector('.memori-widget');
143
+ if (memoriWidget) {
144
+ // Set white background before entering fullscreen
145
+ (memoriWidget as HTMLElement).style.backgroundColor =
146
+ '#FFFFFF';
147
+ memoriWidget.requestFullscreen().catch(err => {
148
+ console.warn('Error attempting to enable fullscreen:', err);
149
+ });
150
+ }
143
151
  setFullScreen(true);
144
152
  } else if (document.exitFullscreen) {
145
- document.exitFullscreen();
153
+ const memoriWidget = document.querySelector('.memori-widget');
154
+ if (memoriWidget) {
155
+ // Reset background on exit
156
+ (memoriWidget as HTMLElement).style.backgroundColor = '';
157
+ }
158
+ document.exitFullscreen().catch(err => {
159
+ console.warn('Error attempting to exit fullscreen:', err);
160
+ });
146
161
  setFullScreen(false);
147
162
  }
148
163
  }}
@@ -13,6 +13,7 @@ import {
13
13
  MemoriSession,
14
14
  User,
15
15
  ExpertReference,
16
+ ResponseSpec,
16
17
  } from '@memori.ai/memori-api-client/src/types';
17
18
  import {
18
19
  SpeakerAudioDestination,
@@ -31,11 +32,7 @@ import React, {
31
32
  } from 'react';
32
33
  import { useTranslation } from 'react-i18next';
33
34
  import memoriApiClient from '@memori.ai/memori-api-client';
34
- import {
35
- AudioContext,
36
- IAudioBufferSourceNode,
37
- IAudioContext,
38
- } from 'standardized-audio-context';
35
+ import { AudioContext, IAudioContext } from 'standardized-audio-context';
39
36
  import * as speechSdk from 'microsoft-cognitiveservices-speech-sdk';
40
37
  import cx from 'classnames';
41
38
  import { DateTime } from 'luxon';
@@ -54,12 +51,16 @@ import SettingsDrawer from '../SettingsDrawer/SettingsDrawer';
54
51
  import KnownFacts from '../KnownFacts/KnownFacts';
55
52
  import ExpertsDrawer from '../ExpertsDrawer/ExpertsDrawer';
56
53
  import LoginDrawer from '../LoginDrawer/LoginDrawer';
54
+ import Button from '../ui/Button';
55
+ import CloseIcon from '../icons/Close';
57
56
 
58
57
  // Layout
59
58
  import FullPageLayout from '../layouts/FullPage';
60
59
  import TotemLayout from '../layouts/Totem';
61
60
  import ChatLayout from '../layouts/Chat';
62
61
  import WebsiteAssistantLayout from '../layouts/WebsiteAssistant';
62
+ import HiddenChatLayout from '../layouts/HiddenChat';
63
+ import ZoomedFullBodyLayout from '../layouts/ZoomedFullBody';
63
64
 
64
65
  // Helpers / Utils
65
66
  import { getTranslation } from '../../helpers/translations';
@@ -85,8 +86,6 @@ import {
85
86
  } from '../../helpers/constants';
86
87
  import { getErrori18nKey } from '../../helpers/error';
87
88
  import { getCredits } from '../../helpers/credits';
88
- import HiddenChatLayout from '../layouts/HiddenChat';
89
- import ZoomedFullBodyLayout from '../layouts/ZoomedFullBody';
90
89
  import { useViseme } from '../../context/visemeContext';
91
90
 
92
91
  // Widget utilities and helpers
@@ -1103,10 +1102,14 @@ const MemoriWidget = ({
1103
1102
  */
1104
1103
  const fetchSession = async (
1105
1104
  params: OpenSession
1106
- ): Promise<{
1107
- dialogState: DialogState;
1108
- sessionID: string;
1109
- } | void> => {
1105
+ ): Promise<
1106
+ | (ResponseSpec & {
1107
+ dialogState?: DialogState;
1108
+ sessionID: string;
1109
+ })
1110
+ | undefined
1111
+ | void
1112
+ > => {
1110
1113
  let storageBirthDate = getLocalConfig<string | undefined>(
1111
1114
  'birthDate',
1112
1115
  undefined
@@ -1186,7 +1189,7 @@ const MemoriWidget = ({
1186
1189
  return {
1187
1190
  dialogState: session.currentState,
1188
1191
  sessionID: session.sessionID,
1189
- } as { dialogState: DialogState; sessionID: string };
1192
+ } as any;
1190
1193
  }
1191
1194
  // Handle age restriction error
1192
1195
  else if (
@@ -1200,12 +1203,31 @@ const MemoriWidget = ({
1200
1203
  else if (session?.resultCode === 403) {
1201
1204
  setMemoriPwd(undefined);
1202
1205
  setAuthModalState('password');
1206
+ return session;
1203
1207
  }
1204
1208
  // Handle other errors
1205
1209
  else {
1206
1210
  console.warn(session);
1207
- toast.error(t(getErrori18nKey(session?.resultCode)));
1211
+ toast.error(
1212
+ tst => (
1213
+ <div>
1214
+ <p>{t(getErrori18nKey(session?.resultCode))}</p>
1215
+ <Button
1216
+ outlined
1217
+ padded={false}
1218
+ onClick={() => toast.dismiss(tst.id)}
1219
+ icon={<CloseIcon />}
1220
+ >
1221
+ {t('close')}
1222
+ </Button>
1223
+ </div>
1224
+ ),
1225
+ {
1226
+ duration: Infinity,
1227
+ }
1228
+ );
1208
1229
  setGotErrorInOpening(true);
1230
+ return session;
1209
1231
  }
1210
1232
  } catch (err) {
1211
1233
  console.error(err);
@@ -2844,9 +2866,11 @@ const MemoriWidget = ({
2844
2866
  .finally(() => {
2845
2867
  setHasUserActivatedSpeak(true);
2846
2868
  });
2847
- } else {
2869
+ } else if (session?.resultCode === 0) {
2848
2870
  // console.log('[CLICK_START] Retrying with session:', session);
2849
- await onClickStart(session || undefined);
2871
+ await onClickStart((session as any) || undefined);
2872
+ } else {
2873
+ setLoading(false);
2850
2874
  }
2851
2875
 
2852
2876
  return;
@@ -1616,13 +1616,13 @@ exports[`renders StartPanel with multilangual unchanged 1`] = `
1616
1616
  </option>
1617
1617
  <option
1618
1618
  aria-label="中文"
1619
- value="ZH"
1619
+ value="JA"
1620
1620
  >
1621
1621
  中文
1622
1622
  </option>
1623
1623
  <option
1624
1624
  aria-label="日本語"
1625
- value="JA"
1625
+ value="ZH"
1626
1626
  >
1627
1627
  日本語
1628
1628
  </option>
@@ -325,13 +325,13 @@ exports[`renders Chat layout unchanged 1`] = `
325
325
  </option>
326
326
  <option
327
327
  aria-label="中文"
328
- value="ZH"
328
+ value="JA"
329
329
  >
330
330
  中文
331
331
  </option>
332
332
  <option
333
333
  aria-label="日本語"
334
- value="JA"
334
+ value="ZH"
335
335
  >
336
336
  日本語
337
337
  </option>
@@ -364,13 +364,13 @@ exports[`renders FullPage layout unchanged 1`] = `
364
364
  </option>
365
365
  <option
366
366
  aria-label="中文"
367
- value="ZH"
367
+ value="JA"
368
368
  >
369
369
  中文
370
370
  </option>
371
371
  <option
372
372
  aria-label="日本語"
373
- value="JA"
373
+ value="ZH"
374
374
  >
375
375
  日本語
376
376
  </option>
@@ -826,13 +826,13 @@ exports[`renders FullPage layout with root css properties unchanged 1`] = `
826
826
  </option>
827
827
  <option
828
828
  aria-label="中文"
829
- value="ZH"
829
+ value="JA"
830
830
  >
831
831
  中文
832
832
  </option>
833
833
  <option
834
834
  aria-label="日本語"
835
- value="JA"
835
+ value="ZH"
836
836
  >
837
837
  日本語
838
838
  </option>
@@ -418,13 +418,13 @@ exports[`renders Totem layout unchanged 1`] = `
418
418
  </option>
419
419
  <option
420
420
  aria-label="中文"
421
- value="ZH"
421
+ value="JA"
422
422
  >
423
423
  中文
424
424
  </option>
425
425
  <option
426
426
  aria-label="日本語"
427
- value="JA"
427
+ value="ZH"
428
428
  >
429
429
  日本語
430
430
  </option>
@@ -364,13 +364,13 @@ exports[`renders ZOOMED_FULL_BODY layout unchanged 1`] = `
364
364
  </option>
365
365
  <option
366
366
  aria-label="中文"
367
- value="ZH"
367
+ value="JA"
368
368
  >
369
369
  中文
370
370
  </option>
371
371
  <option
372
372
  aria-label="日本語"
373
- value="JA"
373
+ value="ZH"
374
374
  >
375
375
  日本語
376
376
  </option>
@@ -11,8 +11,8 @@ export const chatLanguages = [
11
11
  { value: 'FI', label: 'Suomi' },
12
12
  { value: 'EL', label: 'Ελληνικά' },
13
13
  { value: 'AR', label: 'العربية' },
14
- { value: 'ZH', label: '中文' },
15
- { value: 'JA', label: '日本語' },
14
+ { value: 'JA', label: '中文' },
15
+ { value: 'ZH', label: '日本語' },
16
16
  ];
17
17
 
18
18
  export const uiLanguages = ['en', 'it', 'fr', 'es', 'de'];