react-native-srschat 0.1.83 → 0.1.85

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.
Files changed (59) hide show
  1. package/lib/commonjs/components/email.js +5 -9
  2. package/lib/commonjs/components/email.js.map +1 -1
  3. package/lib/commonjs/components/productCard.js +91 -86
  4. package/lib/commonjs/components/productCard.js.map +1 -1
  5. package/lib/commonjs/components/welcomeButton.js +4 -4
  6. package/lib/commonjs/components/welcomeButton.js.map +1 -1
  7. package/lib/commonjs/contexts/AppContext.js +46 -45
  8. package/lib/commonjs/contexts/AppContext.js.map +1 -1
  9. package/lib/commonjs/hooks/Stream.js +399 -74
  10. package/lib/commonjs/hooks/Stream.js.map +1 -1
  11. package/lib/commonjs/layout/disclaimer.js +36 -32
  12. package/lib/commonjs/layout/disclaimer.js.map +1 -1
  13. package/lib/commonjs/layout/welcome.js +8 -7
  14. package/lib/commonjs/layout/welcome.js.map +1 -1
  15. package/lib/commonjs/layout/window.js +152 -131
  16. package/lib/commonjs/layout/window.js.map +1 -1
  17. package/lib/commonjs/utils/audioRecorder.js.map +1 -1
  18. package/lib/commonjs/utils/storage.js +1 -1
  19. package/lib/module/components/email.js +5 -9
  20. package/lib/module/components/email.js.map +1 -1
  21. package/lib/module/components/productCard.js +94 -89
  22. package/lib/module/components/productCard.js.map +1 -1
  23. package/lib/module/components/welcomeButton.js +4 -4
  24. package/lib/module/components/welcomeButton.js.map +1 -1
  25. package/lib/module/contexts/AppContext.js +47 -46
  26. package/lib/module/contexts/AppContext.js.map +1 -1
  27. package/lib/module/hooks/Stream.js +400 -75
  28. package/lib/module/hooks/Stream.js.map +1 -1
  29. package/lib/module/layout/disclaimer.js +41 -37
  30. package/lib/module/layout/disclaimer.js.map +1 -1
  31. package/lib/module/layout/welcome.js +8 -7
  32. package/lib/module/layout/welcome.js.map +1 -1
  33. package/lib/module/layout/window.js +152 -131
  34. package/lib/module/layout/window.js.map +1 -1
  35. package/lib/module/utils/audioRecorder.js.map +1 -1
  36. package/lib/module/utils/storage.js +1 -1
  37. package/lib/typescript/components/email.d.ts.map +1 -1
  38. package/lib/typescript/components/productCard.d.ts +1 -1
  39. package/lib/typescript/components/productCard.d.ts.map +1 -1
  40. package/lib/typescript/components/welcomeButton.d.ts.map +1 -1
  41. package/lib/typescript/contexts/AppContext.d.ts +2 -2
  42. package/lib/typescript/contexts/AppContext.d.ts.map +1 -1
  43. package/lib/typescript/hooks/Stream.d.ts.map +1 -1
  44. package/lib/typescript/layout/disclaimer.d.ts +1 -1
  45. package/lib/typescript/layout/disclaimer.d.ts.map +1 -1
  46. package/lib/typescript/layout/welcome.d.ts.map +1 -1
  47. package/lib/typescript/layout/window.d.ts.map +1 -1
  48. package/lib/typescript/utils/audioRecorder.d.ts.map +1 -1
  49. package/package.json +2 -1
  50. package/src/components/email.js +4 -16
  51. package/src/components/productCard.js +279 -203
  52. package/src/components/welcomeButton.js +10 -10
  53. package/src/contexts/AppContext.js +185 -106
  54. package/src/hooks/Stream.js +607 -237
  55. package/src/layout/disclaimer.js +125 -78
  56. package/src/layout/welcome.js +58 -20
  57. package/src/layout/window.js +279 -140
  58. package/src/utils/audioRecorder.js +40 -34
  59. package/src/utils/storage.ts +2 -2
@@ -48,7 +48,7 @@ export async function initVoice(onResult, onPartialResult = null) {
48
48
  Voice.removeAllListeners();
49
49
 
50
50
  // Set up all event listeners
51
- Voice.onSpeechStart = (e) => {
51
+ Voice.onSpeechStart = e => {
52
52
  console.log('onSpeechStart: ', e);
53
53
  isCurrentlyRecording = true;
54
54
  finalResult = '';
@@ -57,7 +57,7 @@ export async function initVoice(onResult, onPartialResult = null) {
57
57
  handleSilenceDetection();
58
58
  };
59
59
 
60
- Voice.onSpeechRecognized = (e) => {
60
+ Voice.onSpeechRecognized = e => {
61
61
  console.log('onSpeechRecognized: ', e);
62
62
  if (e.isFinal) {
63
63
  console.log('Speech recognition final');
@@ -65,9 +65,9 @@ export async function initVoice(onResult, onPartialResult = null) {
65
65
  }
66
66
  };
67
67
 
68
- Voice.onSpeechEnd = async (e) => {
68
+ Voice.onSpeechEnd = async e => {
69
69
  console.log('onSpeechEnd: ', e);
70
-
70
+
71
71
  if (silenceTimer) {
72
72
  clearTimeout(silenceTimer);
73
73
  silenceTimer = null;
@@ -79,9 +79,9 @@ export async function initVoice(onResult, onPartialResult = null) {
79
79
  }
80
80
  };
81
81
 
82
- Voice.onSpeechError = async (e) => {
82
+ Voice.onSpeechError = async e => {
83
83
  console.log('onSpeechError: ', e);
84
-
84
+
85
85
  if (silenceTimer) {
86
86
  clearTimeout(silenceTimer);
87
87
  silenceTimer = null;
@@ -89,7 +89,7 @@ export async function initVoice(onResult, onPartialResult = null) {
89
89
 
90
90
  const code = e.error?.code?.toString();
91
91
  const msg = e.error?.message || '';
92
-
92
+
93
93
  // Handle Android-specific errors
94
94
  if (Platform.OS === 'android' && (code === '7' || code === '5')) {
95
95
  if (finalResult && resultCallback) {
@@ -98,11 +98,11 @@ export async function initVoice(onResult, onPartialResult = null) {
98
98
  } else if (!msg.includes('No speech detected') && resultCallback) {
99
99
  resultCallback(null, msg);
100
100
  }
101
-
101
+
102
102
  await cleanupVoiceSession();
103
103
  };
104
104
 
105
- Voice.onSpeechResults = (e) => {
105
+ Voice.onSpeechResults = e => {
106
106
  console.log('onSpeechResults: ', e);
107
107
  if (e.value && e.value.length > 0) {
108
108
  finalResult = e.value[0];
@@ -110,7 +110,7 @@ export async function initVoice(onResult, onPartialResult = null) {
110
110
  }
111
111
  };
112
112
 
113
- Voice.onSpeechPartialResults = (e) => {
113
+ Voice.onSpeechPartialResults = e => {
114
114
  console.log('onSpeechPartialResults: ', e);
115
115
 
116
116
  if (silenceTimer) {
@@ -131,7 +131,7 @@ export async function initVoice(onResult, onPartialResult = null) {
131
131
  };
132
132
 
133
133
  if (Platform.OS === 'android') {
134
- Voice.onSpeechVolumeChanged = (e) => {
134
+ Voice.onSpeechVolumeChanged = e => {
135
135
  console.log('onSpeechVolumeChanged: ', e);
136
136
  };
137
137
  }
@@ -147,7 +147,7 @@ const handleSilenceDetection = () => {
147
147
  if (silenceTimer) {
148
148
  clearTimeout(silenceTimer);
149
149
  }
150
-
150
+
151
151
  silenceTimer = setTimeout(async () => {
152
152
  if (isCurrentlyRecording) {
153
153
  await handleFinalResult();
@@ -176,7 +176,7 @@ const handleFinalResult = async () => {
176
176
  const cleanupVoiceSession = async () => {
177
177
  console.log('cleanupVoiceSession called');
178
178
  isCurrentlyRecording = false;
179
-
179
+
180
180
  if (silenceTimer) {
181
181
  clearTimeout(silenceTimer);
182
182
  silenceTimer = null;
@@ -192,7 +192,7 @@ const cleanupVoiceSession = async () => {
192
192
  // Check if still recognizing
193
193
  const isRecognizing = await Voice.isRecognizing();
194
194
  console.log('Voice.isRecognizing() in cleanup:', isRecognizing);
195
-
195
+
196
196
  if (isRecognizing) {
197
197
  try {
198
198
  // For iOS, use cancel for immediate termination
@@ -217,7 +217,6 @@ const cleanupVoiceSession = async () => {
217
217
  } catch (e) {
218
218
  console.log('Error destroying in cleanup:', e);
219
219
  }
220
-
221
220
  } catch (error) {
222
221
  console.error('Error in cleanupVoiceSession:', error);
223
222
  }
@@ -270,7 +269,7 @@ export async function startRecording() {
270
269
  export async function stopRecording() {
271
270
  try {
272
271
  console.log('stopRecording called');
273
-
272
+
274
273
  if (!isCurrentlyRecording || !Voice) {
275
274
  console.log('Not recording or Voice not available');
276
275
  return;
@@ -335,25 +334,27 @@ export async function cancelRecording() {
335
334
  export async function requestAudioPermission() {
336
335
  try {
337
336
  // Get stored permission if available
338
- const storedPermission = permissionStatusGetter ? permissionStatusGetter() : null;
339
-
337
+ const storedPermission = permissionStatusGetter
338
+ ? permissionStatusGetter()
339
+ : null;
340
+
340
341
  if (storedPermission === 'denied') {
341
342
  console.log('Permission previously denied by user');
342
343
  return false;
343
344
  }
344
-
345
+
345
346
  let permissionResult = false;
346
347
  if (Platform.OS === 'android') {
347
348
  permissionResult = await requestAndroidPermission();
348
349
  } else if (Platform.OS === 'ios') {
349
350
  permissionResult = await requestIOSPermission();
350
351
  }
351
-
352
+
352
353
  // Store the result
353
354
  if (permissionStatusSetter) {
354
355
  permissionStatusSetter(permissionResult ? 'granted' : 'denied');
355
356
  }
356
-
357
+
357
358
  return permissionResult;
358
359
  } catch (error) {
359
360
  console.error('Error checking stored permission:', error);
@@ -381,7 +382,7 @@ async function requestAndroidPermission() {
381
382
  console.log('Error checking speech services:', e);
382
383
  // Continue anyway - some devices report error but work fine
383
384
  }
384
-
385
+
385
386
  return true;
386
387
  } catch (error) {
387
388
  console.error('Error requesting Android permission:', error);
@@ -425,15 +426,20 @@ export function cleanup() {
425
426
  console.log('Voice module not available during cleanup');
426
427
  return;
427
428
  }
428
-
429
- Voice.destroy().then(() => {
430
- Voice.removeAllListeners();
431
- cleanupVoiceSession();
432
- }).catch(error => {
433
- console.error('Error in cleanup:', error);
434
- // Try one more time
435
- if (Voice) {
436
- Voice.destroy().catch(e => console.error('Final cleanup attempt failed:', e));
437
- }
438
- });
439
- }
429
+
430
+ Voice.destroy()
431
+ .then(() => {
432
+ Voice.removeAllListeners();
433
+ cleanupVoiceSession();
434
+ })
435
+ .catch(error => {
436
+ console.error('Error in cleanup:', error);
437
+ // Try one more time
438
+ if (Voice) {
439
+ Voice.destroy().catch(e =>
440
+ console.error('Final cleanup attempt failed:', e),
441
+ );
442
+ }
443
+ });
444
+ }
445
+
@@ -33,7 +33,7 @@ export const defaultState: ChatState = {
33
33
  startStreaming: false,
34
34
  messages: [{
35
35
  type: "ai",
36
- text: "Hi there 👋 Hi there 👋 I'm your Heritage Pool+ AI Assistant. I'm here to help you with Product and Account information during your online visit. I'm still learning and growing - the more we interact and the more feedback you share, the better I can assist you. How can I help you today?"
36
+ text: "Hi there 👋 Hi there 👋 I'm your Heritage+ AI Assistant. I'm here to help you with Product and Account information during your online visit. I'm still learning and growing - the more we interact and the more feedback you share, the better I can assist you. How can I help you today?"
37
37
  }],
38
38
  showIcon: true,
39
39
  toggleChat: false,
@@ -86,4 +86,4 @@ export const updateChat = async (token: string, next: ChatState): Promise<void>
86
86
  } catch (error) {
87
87
  console.error('Error updating chat state:', error);
88
88
  }
89
- };
89
+ };