react-native-srschat 0.1.68 → 0.1.70

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 (62) hide show
  1. package/README.md +1 -0
  2. package/lib/commonjs/components/email.js +57 -53
  3. package/lib/commonjs/components/email.js.map +1 -1
  4. package/lib/commonjs/components/header.js +10 -6
  5. package/lib/commonjs/components/header.js.map +1 -1
  6. package/lib/commonjs/components/productCard.js +46 -3
  7. package/lib/commonjs/components/productCard.js.map +1 -1
  8. package/lib/commonjs/components/welcomeButton.js +23 -4
  9. package/lib/commonjs/components/welcomeButton.js.map +1 -1
  10. package/lib/commonjs/contexts/AppContext.js +37 -11
  11. package/lib/commonjs/contexts/AppContext.js.map +1 -1
  12. package/lib/commonjs/layout/disclaimer.js +13 -8
  13. package/lib/commonjs/layout/disclaimer.js.map +1 -1
  14. package/lib/commonjs/layout/welcome.js +13 -5
  15. package/lib/commonjs/layout/welcome.js.map +1 -1
  16. package/lib/commonjs/layout/window.js +11 -4
  17. package/lib/commonjs/layout/window.js.map +1 -1
  18. package/lib/commonjs/utils/audioRecorder.js +11 -5
  19. package/lib/commonjs/utils/audioRecorder.js.map +1 -1
  20. package/lib/commonjs/utils/cloudinary.js +12 -4
  21. package/lib/commonjs/utils/cloudinary.js.map +1 -1
  22. package/lib/module/components/email.js +57 -53
  23. package/lib/module/components/email.js.map +1 -1
  24. package/lib/module/components/header.js +10 -6
  25. package/lib/module/components/header.js.map +1 -1
  26. package/lib/module/components/productCard.js +46 -3
  27. package/lib/module/components/productCard.js.map +1 -1
  28. package/lib/module/components/welcomeButton.js +23 -4
  29. package/lib/module/components/welcomeButton.js.map +1 -1
  30. package/lib/module/contexts/AppContext.js +37 -11
  31. package/lib/module/contexts/AppContext.js.map +1 -1
  32. package/lib/module/layout/disclaimer.js +13 -8
  33. package/lib/module/layout/disclaimer.js.map +1 -1
  34. package/lib/module/layout/welcome.js +13 -5
  35. package/lib/module/layout/welcome.js.map +1 -1
  36. package/lib/module/layout/window.js +11 -4
  37. package/lib/module/layout/window.js.map +1 -1
  38. package/lib/module/utils/audioRecorder.js +11 -5
  39. package/lib/module/utils/audioRecorder.js.map +1 -1
  40. package/lib/module/utils/cloudinary.js +10 -3
  41. package/lib/module/utils/cloudinary.js.map +1 -1
  42. package/lib/typescript/components/email.d.ts.map +1 -1
  43. package/lib/typescript/components/header.d.ts.map +1 -1
  44. package/lib/typescript/components/productCard.d.ts +1 -1
  45. package/lib/typescript/components/productCard.d.ts.map +1 -1
  46. package/lib/typescript/components/welcomeButton.d.ts.map +1 -1
  47. package/lib/typescript/contexts/AppContext.d.ts.map +1 -1
  48. package/lib/typescript/layout/welcome.d.ts.map +1 -1
  49. package/lib/typescript/layout/window.d.ts.map +1 -1
  50. package/lib/typescript/utils/audioRecorder.d.ts.map +1 -1
  51. package/lib/typescript/utils/cloudinary.d.ts.map +1 -1
  52. package/package.json +1 -1
  53. package/src/components/email.js +61 -54
  54. package/src/components/header.js +6 -9
  55. package/src/components/productCard.js +45 -3
  56. package/src/components/welcomeButton.js +14 -4
  57. package/src/contexts/AppContext.js +42 -13
  58. package/src/layout/disclaimer.js +6 -8
  59. package/src/layout/welcome.js +5 -8
  60. package/src/layout/window.js +8 -5
  61. package/src/utils/audioRecorder.js +18 -13
  62. package/src/utils/cloudinary.js +6 -3
@@ -15,7 +15,7 @@ import { ProgressCircle } from '../components/progressCircle';
15
15
 
16
16
  export const ChatWindow = ({ panHandlers }) => {
17
17
  const { handleSend, messages, input, setInput, ghostMessage, handleButtonClick,
18
- onProductCardClick, onAddToCartClick, uiConfig, ghostCard, typingIndicator, feedbackOpen, setFeedbackOpen
18
+ onProductCardClick, onAddToCartClick, uiConfig, ghostCard, typingIndicator, feedbackOpen, setFeedbackOpen, theme
19
19
  } = useContext(AppContext);
20
20
 
21
21
  const scrollViewRef = useRef(null);
@@ -106,7 +106,7 @@ export const ChatWindow = ({ panHandlers }) => {
106
106
 
107
107
  <View key={msg.id || msg.message_id || i} style={styles.messageWrapper}>
108
108
  {msg.type !== "middle" && (
109
- <View style={[ styles.messageBubble, msg.type === "user" ? styles.userMessage : styles.aiMessage,]}>
109
+ <View style={[ styles.messageBubble, msg.type === "user" ? [styles.userMessage, { backgroundColor: theme.userMessage }] : styles.aiMessage,]}>
110
110
 
111
111
  <Markdown style={{ body: { color: msg.type === "user" ? "#ffffff" : "#161616",fontSize: 16, lineHeight: 22, includeFontPadding: false, textAlignVertical: 'center' }}}>
112
112
  {typeof msg.text === 'string' ? msg.text : String(msg.text || '')}
@@ -149,9 +149,12 @@ export const ChatWindow = ({ panHandlers }) => {
149
149
 
150
150
  {msg.suggested_questions && Array.isArray(msg.questions) && msg.questions.length > 0 &&
151
151
  msg.questions.map((question, index) => (
152
- <TouchableOpacity key={index} style={styles.suggestedQuestionButton}
153
- onPress={() => handleButtonClick(question)}>
154
- <Text style={styles.suggestedQuestionText}>{question}</Text>
152
+ <TouchableOpacity
153
+ key={index}
154
+ style={[styles.suggestedQuestionButton, { borderColor: theme.primaryColor }]}
155
+ onPress={() => handleButtonClick(question)}
156
+ >
157
+ <Text style={[styles.suggestedQuestionText, { color: theme.primaryColor }]}>{question}</Text>
155
158
  </TouchableOpacity>
156
159
  ))}
157
160
 
@@ -52,11 +52,9 @@ export async function initVoice(onResult, onPartialResult = null) {
52
52
  console.log('onSpeechStart: ', e);
53
53
  isCurrentlyRecording = true;
54
54
  finalResult = '';
55
-
56
- if (silenceTimer) {
57
- clearTimeout(silenceTimer);
58
- silenceTimer = null;
59
- }
55
+
56
+ // Start silence timer immediately when recording begins
57
+ handleSilenceDetection();
60
58
  };
61
59
 
62
60
  Voice.onSpeechRecognized = (e) => {
@@ -158,14 +156,16 @@ const handleSilenceDetection = () => {
158
156
 
159
157
  const handleFinalResult = async () => {
160
158
  if (!isCurrentlyRecording) return;
161
-
159
+
162
160
  console.log('handleFinalResult called with:', finalResult);
163
-
161
+
162
+ // Call the result callback first to update UI (button state)
163
+ // This ensures the button changes from stop to microphone immediately
164
164
  if (finalResult && resultCallback) {
165
165
  resultCallback(finalResult, null);
166
166
  }
167
-
168
- // Stop recording first
167
+
168
+ // Then stop recording
169
169
  await stopRecording();
170
170
  };
171
171
 
@@ -224,7 +224,7 @@ const cleanupVoiceSession = async () => {
224
224
  export async function startRecording() {
225
225
  try {
226
226
  console.log('startRecording called');
227
-
227
+
228
228
  // Check if Voice module is available
229
229
  if (!Voice) {
230
230
  console.error('Voice module is not available');
@@ -233,10 +233,10 @@ export async function startRecording() {
233
233
 
234
234
  // Ensure cleanup of any existing session
235
235
  await cleanupVoiceSession();
236
-
236
+
237
237
  // Small delay to ensure cleanup is complete
238
238
  await new Promise(resolve => setTimeout(resolve, 200));
239
-
239
+
240
240
  const hasPermission = await requestAudioPermission();
241
241
  if (!hasPermission) {
242
242
  console.error('No permission to record audio');
@@ -245,11 +245,16 @@ export async function startRecording() {
245
245
 
246
246
  // Re-initialize listeners each time for iOS stability
247
247
  await initVoice(resultCallback, partialResultCallback);
248
-
248
+
249
249
  // Start recognition
250
250
  await Voice.start('en-US');
251
251
  console.log('Voice.start() completed');
252
252
  isCurrentlyRecording = true;
253
+
254
+ // Start silence detection timer immediately
255
+ // This ensures recording stops after 3 seconds even if no speech is detected
256
+ handleSilenceDetection();
257
+
253
258
  return true;
254
259
  } catch (error) {
255
260
  console.error('Error starting voice recognition:', error);
@@ -1,13 +1,15 @@
1
- import React from 'react';
1
+ import React, { useContext } from 'react';
2
2
  import { Cloudinary } from '@cloudinary/url-gen';
3
3
  import { Platform, View } from 'react-native';
4
4
  import { AdvancedImage } from 'cloudinary-react-native';
5
5
  import { scale } from '@cloudinary/url-gen/actions/resize';
6
+ import { AppContext } from '../contexts/AppContext';
6
7
 
7
8
  const CloudinaryImage = ({ cldImg, imageStyle, accessibilityLabel, testID }) => {
9
+ const { brandCloudName } = useContext(AppContext);
8
10
  const cld = new Cloudinary({
9
11
  cloud: {
10
- cloudName: 'mktg'
12
+ cloudName: brandCloudName || 'mktg'
11
13
  }
12
14
  });
13
15
 
@@ -32,9 +34,10 @@ export const CloudinaryBannerImage = ({
32
34
  width = 345,
33
35
  height = 100
34
36
  }) => {
37
+ const { brandCloudName } = useContext(AppContext);
35
38
  const cld = new Cloudinary({
36
39
  cloud: {
37
- cloudName: 'mktg'
40
+ cloudName: brandCloudName || 'mktg'
38
41
  }
39
42
  });
40
43
  const myImage = cld.image(`${cldImg}`);