@revrag-ai/embed-react-native 1.0.6 → 1.0.8

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 (91) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +253 -274
  3. package/android/CMakeLists.txt +15 -0
  4. package/android/build.gradle +77 -25
  5. package/android/cpp-adapter.cpp +8 -0
  6. package/android/generated/java/com/revragai/embedreactnative/NativeEmbedReactNativeSpec.java +37 -0
  7. package/android/generated/jni/CMakeLists.txt +49 -0
  8. package/android/generated/jni/RNEmbedReactNativeSpec-generated.cpp +32 -0
  9. package/android/generated/jni/RNEmbedReactNativeSpec.h +31 -0
  10. package/android/generated/jni/react/renderer/components/RNEmbedReactNativeSpec/RNEmbedReactNativeSpecJSI-generated.cpp +28 -0
  11. package/android/generated/jni/react/renderer/components/RNEmbedReactNativeSpec/RNEmbedReactNativeSpecJSI.h +67 -0
  12. package/android/gradle.properties +5 -5
  13. package/cpp/revrag-ai-embed-react-native.cpp +7 -0
  14. package/cpp/revrag-ai-embed-react-native.h +8 -0
  15. package/ios/EmbedReactNative.h +9 -0
  16. package/ios/{Onwid.mm → EmbedReactNative.mm} +4 -4
  17. package/ios/generated/RNEmbedReactNativeSpec/RNEmbedReactNativeSpec-generated.mm +29 -0
  18. package/ios/generated/RNEmbedReactNativeSpec/RNEmbedReactNativeSpec.h +50 -0
  19. package/ios/generated/RNEmbedReactNativeSpecJSI-generated.cpp +28 -0
  20. package/ios/generated/RNEmbedReactNativeSpecJSI.h +67 -0
  21. package/lib/commonjs/NativeEmbedReactNative.js +9 -0
  22. package/{dist/commonjs/onwidApi → lib/commonjs/api}/api.js +86 -15
  23. package/lib/commonjs/api/types/embed.api.types.js +2 -0
  24. package/{dist/module/component/audiowave.js → lib/commonjs/components/Embed/EmbedAudioWave.js} +21 -17
  25. package/{dist/module/component/OnwidButton.js → lib/commonjs/components/Embed/EmbedButton.js} +65 -61
  26. package/{dist/module/component/voice.js → lib/commonjs/components/Embed/EmbedVoice.js} +18 -14
  27. package/{dist/commonjs/style/onwidButton.style.js → lib/commonjs/components/styles/EmbedButton.style.js} +14 -9
  28. package/{dist/module/Event/onwid.js → lib/commonjs/events/embed.event.js} +14 -10
  29. package/{dist → lib}/commonjs/hooks/initialize.js +22 -22
  30. package/{dist/commonjs/hooks/initializelivekit.js → lib/commonjs/hooks/initialize.livekit.js} +8 -5
  31. package/lib/commonjs/hooks/types/voiceAgent.types.js +6 -0
  32. package/{dist/module/hooks/voiceAgent.js → lib/commonjs/hooks/voiceagent.js} +36 -31
  33. package/lib/commonjs/index.js +34 -0
  34. package/{dist/module/index.d.js → lib/commonjs/index.types.js} +7 -7
  35. package/lib/commonjs/store/store.key.js +46 -0
  36. package/{dist/module/utils/reanimatedHelpers.js → lib/commonjs/utils/reanimated.helper.js} +23 -17
  37. package/lib/module/NativeEmbedReactNative.js +5 -0
  38. package/{dist/module/onwidApi → lib/module/api}/api.js +69 -6
  39. package/lib/module/api/types/embed.api.types.js +2 -0
  40. package/{dist/commonjs/component/audiowave.js → lib/module/components/Embed/EmbedAudioWave.js} +2 -3
  41. package/{dist/commonjs/component/OnwidButton.js → lib/module/components/Embed/EmbedButton.js} +10 -11
  42. package/{dist/commonjs/component/voice.js → lib/module/components/Embed/EmbedVoice.js} +1 -1
  43. package/{dist/module/style/onwidButton.style.js → lib/module/components/styles/EmbedButton.style.js} +3 -3
  44. package/{dist/commonjs/Event/onwid.js → lib/module/events/embed.event.js} +6 -6
  45. package/{dist → lib}/module/hooks/initialize.js +7 -13
  46. package/{dist/module/hooks/initializelivekit.js → lib/module/hooks/initialize.livekit.js} +1 -1
  47. package/{dist/commonjs/hooks/voiceAgent.js → lib/module/hooks/voiceagent.js} +4 -4
  48. package/lib/module/index.js +7 -0
  49. package/{dist/commonjs/index.d.js → lib/module/index.types.js} +2 -1
  50. package/{dist/commonjs/utils/reanimatedHelpers.js → lib/module/utils/reanimated.helper.js} +14 -14
  51. package/lib/typescript/module/package.json +1 -0
  52. package/package.json +71 -35
  53. package/react-native.config.js +8 -14
  54. package/revrag-ai-embed-react-native.podspec +41 -0
  55. package/Onwid.podspec +0 -20
  56. package/dist/commonjs/NativeOnwid.js +0 -5
  57. package/dist/commonjs/button.json +0 -1
  58. package/dist/commonjs/index.js +0 -34
  59. package/dist/commonjs/onwidApi/api.types.js +0 -2
  60. package/dist/commonjs/utils/utils.js +0 -2
  61. package/dist/module/NativeOnwid.js +0 -5
  62. package/dist/module/button.json +0 -1
  63. package/dist/module/hooks/voiceAgent.types.js +0 -4
  64. package/dist/module/index.js +0 -34
  65. package/dist/module/onwidApi/api.types.js +0 -2
  66. package/dist/module/store.key.js +0 -38
  67. package/dist/module/utils/utils.js +0 -2
  68. package/dist/typescript/Event/onwid.d.ts +0 -14
  69. package/dist/typescript/NativeOnwid.d.ts +0 -7
  70. package/dist/typescript/component/OnwidButton.d.ts +0 -29
  71. package/dist/typescript/component/audiowave.d.ts +0 -7
  72. package/dist/typescript/component/voice.d.ts +0 -16
  73. package/dist/typescript/hooks/initialize.d.ts +0 -3
  74. package/dist/typescript/hooks/initialize.types.d.ts +0 -6
  75. package/dist/typescript/hooks/initializelivekit.d.ts +0 -4
  76. package/dist/typescript/hooks/voiceAgent.d.ts +0 -3
  77. package/dist/typescript/hooks/voiceAgent.types.d.ts +0 -17
  78. package/dist/typescript/index.d.ts +0 -27
  79. package/dist/typescript/onwidApi/api.d.ts +0 -54
  80. package/dist/typescript/onwidApi/api.types.d.ts +0 -22
  81. package/dist/typescript/store.key.d.ts +0 -4
  82. package/dist/typescript/style/onwidButton.style.d.ts +0 -99
  83. package/dist/typescript/utils/reanimatedHelpers.d.ts +0 -30
  84. package/dist/typescript/utils/utils.d.ts +0 -1
  85. package/ios/Onwid.h +0 -5
  86. package/scripts/verify-setup.js +0 -90
  87. /package/{dist/commonjs/hooks → lib/commonjs/hooks/types}/initialize.types.js +0 -0
  88. /package/{dist/module/hooks → lib/module/hooks/types}/initialize.types.js +0 -0
  89. /package/{dist/commonjs/hooks → lib/module/hooks/types}/voiceAgent.types.js +0 -0
  90. /package/{dist/commonjs → lib/module/store}/store.key.js +0 -0
  91. /package/{dist → lib/typescript}/commonjs/package.json +0 -0
@@ -1,11 +1,14 @@
1
1
  "use strict";
2
2
 
3
- import { getAgentData, setAgentData } from '../store.key';
4
-
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.updateUserData = exports.registerOnInitialize = exports.initializeApi = exports.getTokenDetails = exports.APIService = void 0;
7
+ var _storeKey = require("../store/store.key.js");
5
8
  /**
6
9
  * APIService class that ensures proper initialization before API calls
7
10
  */
8
- export class APIService {
11
+ class APIService {
9
12
  static instance = null;
10
13
  apiBaseUrl = null;
11
14
  isInitialized = false;
@@ -28,10 +31,10 @@ export class APIService {
28
31
  if (this.isInitialized && this.apiBaseUrl) {
29
32
  return; // Already initialized
30
33
  }
31
- const AgentData = await getAgentData();
34
+ const AgentData = await (0, _storeKey.getAgentData)();
32
35
  console.log('AgentData', AgentData);
33
- if (AgentData?.onwidUrl) {
34
- this.apiBaseUrl = AgentData.onwidUrl;
36
+ if (AgentData?.embedUrl) {
37
+ this.apiBaseUrl = AgentData.embedUrl;
35
38
  this.isInitialized = true;
36
39
  console.log('API_BASE_URL initialized:', this.apiBaseUrl);
37
40
  } else {
@@ -52,7 +55,7 @@ export class APIService {
52
55
  * Get headers with stored API key
53
56
  */
54
57
  async getHeaders() {
55
- const AgentData = await getAgentData();
58
+ const AgentData = await (0, _storeKey.getAgentData)();
56
59
  if (!AgentData?.apiKey) {
57
60
  throw new Error('API key not found in keychain');
58
61
  }
@@ -78,7 +81,7 @@ export class APIService {
78
81
  });
79
82
  const data = await response.json();
80
83
  console.log('dat config data after register', data);
81
- await setAgentData(data, '@config_data');
84
+ await (0, _storeKey.setAgentData)(data, '@config_data');
82
85
  if (!response.ok) {
83
86
  console.log('registerOnInitialize error', data.error);
84
87
  throw new Error(data.error || 'Registration failed');
@@ -89,9 +92,30 @@ export class APIService {
89
92
  };
90
93
  } catch (error) {
91
94
  console.log('registerOnInitialize error', error);
95
+
96
+ // Enhanced error handling for common iOS network issues
97
+ let errorMessage = 'Unknown error occurred';
98
+ if (error instanceof Error) {
99
+ errorMessage = error.message;
100
+
101
+ // iOS ATS related errors
102
+ if (error.message.includes('The resource could not be loaded') || error.message.includes('App Transport Security')) {
103
+ errorMessage = `Network request blocked by iOS App Transport Security. ` + `Please configure ATS exceptions in Info.plist for HTTP endpoints, ` + `or use HTTPS instead. Error: ${error.message}`;
104
+ }
105
+
106
+ // Network connectivity errors
107
+ if (error.message.includes('Network request failed') || error.message.includes('Failed to fetch')) {
108
+ errorMessage = `Network request failed. Please check your internet connection ` + `and ensure the API endpoint (${this.apiBaseUrl}) is accessible. ` + `Error: ${error.message}`;
109
+ }
110
+
111
+ // Timeout errors
112
+ if (error.message.includes('timeout')) {
113
+ errorMessage = `Request timeout. The API server may be slow to respond or unreachable. ` + `Error: ${error.message}`;
114
+ }
115
+ }
92
116
  return {
93
117
  success: false,
94
- error: error instanceof Error ? error.message : 'Unknown error occurred'
118
+ error: errorMessage
95
119
  };
96
120
  }
97
121
  }
@@ -124,9 +148,30 @@ export class APIService {
124
148
  };
125
149
  } catch (error) {
126
150
  console.log('updateUserData error', error);
151
+
152
+ // Enhanced error handling for common iOS network issues
153
+ let errorMessage = 'Unknown error occurred';
154
+ if (error instanceof Error) {
155
+ errorMessage = error.message;
156
+
157
+ // iOS ATS related errors
158
+ if (error.message.includes('The resource could not be loaded') || error.message.includes('App Transport Security')) {
159
+ errorMessage = `Network request blocked by iOS App Transport Security. ` + `Please configure ATS exceptions in Info.plist for HTTP endpoints, ` + `or use HTTPS instead. Error: ${error.message}`;
160
+ }
161
+
162
+ // Network connectivity errors
163
+ if (error.message.includes('Network request failed') || error.message.includes('Failed to fetch')) {
164
+ errorMessage = `Network request failed. Please check your internet connection ` + `and ensure the API endpoint (${this.apiBaseUrl}) is accessible. ` + `Error: ${error.message}`;
165
+ }
166
+
167
+ // Timeout errors
168
+ if (error.message.includes('timeout')) {
169
+ errorMessage = `Request timeout. The API server may be slow to respond or unreachable. ` + `Error: ${error.message}`;
170
+ }
171
+ }
127
172
  return {
128
173
  success: false,
129
- error: error instanceof Error ? error.message : 'Unknown error occurred'
174
+ error: errorMessage
130
175
  };
131
176
  }
132
177
  }
@@ -157,29 +202,55 @@ export class APIService {
157
202
  };
158
203
  } catch (error) {
159
204
  console.log('getTokenDetails error', error);
205
+
206
+ // Enhanced error handling for common iOS network issues
207
+ let errorMessage = 'Unknown error occurred';
208
+ if (error instanceof Error) {
209
+ errorMessage = error.message;
210
+
211
+ // iOS ATS related errors
212
+ if (error.message.includes('The resource could not be loaded') || error.message.includes('App Transport Security')) {
213
+ errorMessage = `Network request blocked by iOS App Transport Security. ` + `Please configure ATS exceptions in Info.plist for HTTP endpoints, ` + `or use HTTPS instead. Error: ${error.message}`;
214
+ }
215
+
216
+ // Network connectivity errors
217
+ if (error.message.includes('Network request failed') || error.message.includes('Failed to fetch')) {
218
+ errorMessage = `Network request failed. Please check your internet connection ` + `and ensure the API endpoint (${this.apiBaseUrl}) is accessible. ` + `Error: ${error.message}`;
219
+ }
220
+
221
+ // Timeout errors
222
+ if (error.message.includes('timeout')) {
223
+ errorMessage = `Request timeout. The API server may be slow to respond or unreachable. ` + `Error: ${error.message}`;
224
+ }
225
+ }
160
226
  return {
161
227
  success: false,
162
- error: error instanceof Error ? error.message : 'Unknown error occurred'
228
+ error: errorMessage
163
229
  };
164
230
  }
165
231
  }
166
232
  }
167
233
 
168
234
  // Export convenience functions for backward compatibility
169
- export const initializeApi = async () => {
235
+ exports.APIService = APIService;
236
+ const initializeApi = async () => {
170
237
  const apiService = APIService.getInstance();
171
238
  await apiService.initialize();
172
239
  };
173
- export const registerOnInitialize = async () => {
240
+ exports.initializeApi = initializeApi;
241
+ const registerOnInitialize = async () => {
174
242
  const apiService = APIService.getInstance();
175
243
  return await apiService.registerOnInitialize();
176
244
  };
177
- export const updateUserData = async params => {
245
+ exports.registerOnInitialize = registerOnInitialize;
246
+ const updateUserData = async params => {
178
247
  const apiService = APIService.getInstance();
179
248
  return await apiService.updateUserData(params);
180
249
  };
181
- export const getTokenDetails = async params => {
250
+ exports.updateUserData = updateUserData;
251
+ const getTokenDetails = async params => {
182
252
  const apiService = APIService.getInstance();
183
253
  return await apiService.getTokenDetails(params);
184
254
  };
255
+ exports.getTokenDetails = getTokenDetails;
185
256
  //# sourceMappingURL=api.js.map
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=embed.api.types.js.map
@@ -1,18 +1,22 @@
1
1
  "use strict";
2
2
 
3
- import { useEffect, useRef, useState } from 'react';
4
- import { View, Animated } from 'react-native';
5
- import { jsx as _jsx } from "react/jsx-runtime";
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.WaveformVisualizer = void 0;
7
+ var _react = require("react");
8
+ var _reactNative = require("react-native");
9
+ var _jsxRuntime = require("react/jsx-runtime");
6
10
  // React Native compatible waveform simulator
7
11
  const useReactNativeAudioWaveform = roomRef => {
8
- const [isAudioActive, setIsAudioActive] = useState(false);
9
- const intervalRef = useRef(null);
10
- const [currentHeights, setCurrentHeights] = useState(Array(10).fill(0));
12
+ const [isAudioActive, setIsAudioActive] = (0, _react.useState)(false);
13
+ const intervalRef = (0, _react.useRef)(null);
14
+ const [currentHeights, setCurrentHeights] = (0, _react.useState)(Array(10).fill(0));
11
15
 
12
16
  // Create animated values for each bar
13
17
  const barCount = 10;
14
- const animatedBars = useRef(Array(barCount).fill(0).map(() => new Animated.Value(0))).current;
15
- useEffect(() => {
18
+ const animatedBars = (0, _react.useRef)(Array(barCount).fill(0).map(() => new _reactNative.Animated.Value(0))).current;
19
+ (0, _react.useEffect)(() => {
16
20
  // Check if there's an active room connection AND if agent is talking
17
21
  const checkAudioActivity = () => {
18
22
  const room = roomRef.current;
@@ -59,7 +63,7 @@ const useReactNativeAudioWaveform = roomRef => {
59
63
  }, [roomRef]);
60
64
 
61
65
  // Continuous smooth animation
62
- useEffect(() => {
66
+ (0, _react.useEffect)(() => {
63
67
  const animateWaveform = () => {
64
68
  // Generate smooth waveform data - stop animation completely when not active
65
69
  const targetHeights = isAudioActive ? Array(barCount).fill(0).map((_, index) => {
@@ -74,14 +78,14 @@ const useReactNativeAudioWaveform = roomRef => {
74
78
  setCurrentHeights(targetHeights);
75
79
  const animations = animatedBars.map((animatedValue, index) => {
76
80
  const targetHeight = targetHeights[index] || 0;
77
- return Animated.timing(animatedValue, {
81
+ return _reactNative.Animated.timing(animatedValue, {
78
82
  toValue: targetHeight,
79
83
  duration: isAudioActive ? 400 : 600,
80
84
  // Slower fade out when going inactive
81
85
  useNativeDriver: false
82
86
  });
83
87
  });
84
- Animated.parallel(animations).start();
88
+ _reactNative.Animated.parallel(animations).start();
85
89
  };
86
90
 
87
91
  // Start animation immediately and repeat
@@ -97,16 +101,15 @@ const useReactNativeAudioWaveform = roomRef => {
97
101
  isActive: isAudioActive
98
102
  };
99
103
  };
100
- export const WaveformVisualizer = ({
104
+ const WaveformVisualizer = ({
101
105
  roomRef
102
106
  }) => {
103
107
  const {
104
108
  animatedBars,
105
- currentHeights,
106
- isActive
109
+ currentHeights
107
110
  } = useReactNativeAudioWaveform(roomRef);
108
111
  console.log('animatedBars', animatedBars);
109
- return /*#__PURE__*/_jsx(View, {
112
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
110
113
  style: {
111
114
  flexDirection: 'row',
112
115
  alignItems: 'center',
@@ -133,7 +136,7 @@ export const WaveformVisualizer = ({
133
136
  }
134
137
 
135
138
  // You can use conditionalValue for width, color, or other properties
136
- return /*#__PURE__*/_jsx(Animated.View, {
139
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Animated.View, {
137
140
  style: {
138
141
  width: conditionalValue === 10 ? 4 : 4,
139
142
  borderRadius: 100,
@@ -150,4 +153,5 @@ export const WaveformVisualizer = ({
150
153
  })
151
154
  });
152
155
  };
153
- //# sourceMappingURL=audiowave.js.map
156
+ exports.WaveformVisualizer = WaveformVisualizer;
157
+ //# sourceMappingURL=EmbedAudioWave.js.map
@@ -1,25 +1,30 @@
1
1
  "use strict";
2
2
 
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.EmbedButton = EmbedButton;
7
+ exports.default = void 0;
8
+ var _lottieReactNative = _interopRequireDefault(require("lottie-react-native"));
9
+ var _react = require("react");
10
+ var _reactNative = require("react-native");
11
+ var _reactNativeGestureHandler = require("react-native-gesture-handler");
12
+ var _reactNativeLinearGradient = _interopRequireDefault(require("react-native-linear-gradient"));
13
+ var _voiceagent = require("../../hooks/voiceagent.js");
14
+ var _storeKey = require("../../store/store.key.js");
15
+ var _EmbedButtonStyle = require("../styles/EmbedButton.style.js");
16
+ var _reanimatedHelper = require("../../utils/reanimated.helper.js");
17
+ var _EmbedVoice = _interopRequireDefault(require("./EmbedVoice.js"));
18
+ var _EmbedAudioWave = require("./EmbedAudioWave.js");
19
+ var _jsxRuntime = require("react/jsx-runtime");
20
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
3
21
  /**
4
22
  * @file OnwidButton.tsx
5
23
  * @description A customizable floating action button component for React Native applications.
6
24
  * This component provides a draggable, expandable button with animation support and gradient styling.
7
25
  */
8
26
 
9
- import LottieView from 'lottie-react-native';
10
- import { useEffect, useMemo, useRef, useState } from 'react';
11
- import { Dimensions, Image, Text, TouchableOpacity, View } from 'react-native';
12
- import { Gesture, GestureDetector } from 'react-native-gesture-handler';
13
- import LinearGradient from 'react-native-linear-gradient';
14
- import Voice from '../component/voice';
15
- import { useVoiceAgent } from '../hooks/voiceAgent';
16
- import { getAgentData } from '../store.key';
17
- import { createOnwidButtonStyles } from '../style/onwidButton.style';
18
- import { getReanimatedAPI, showReanimatedSetupError } from '../utils/reanimatedHelpers';
19
- import { WaveformVisualizer } from './audiowave';
20
-
21
27
  // Get reanimated API with fallbacks
22
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
23
28
  const {
24
29
  useSharedValue,
25
30
  useAnimatedStyle,
@@ -31,16 +36,16 @@ const {
31
36
  Easing,
32
37
  Animated,
33
38
  isAvailable: isReanimatedAvailable
34
- } = getReanimatedAPI();
39
+ } = (0, _reanimatedHelper.getReanimatedAPI)();
35
40
 
36
41
  // Show warning if reanimated is not available
37
42
  if (!isReanimatedAvailable) {
38
- showReanimatedSetupError();
43
+ (0, _reanimatedHelper.showReanimatedSetupError)();
39
44
  }
40
45
  const {
41
46
  width: SCREEN_WIDTH,
42
47
  height: SCREEN_HEIGHT
43
- } = Dimensions.get('window');
48
+ } = _reactNative.Dimensions.get('window');
44
49
  const BUTTON_WIDTH = 60;
45
50
  const EXPANDED_WIDTH = SCREEN_WIDTH * 0.9;
46
51
  const BUTTON_HEIGHT = 60;
@@ -90,7 +95,7 @@ const defaultStyles = {
90
95
  * />
91
96
  * ```
92
97
  */
93
- export function OnwidButton() {
98
+ function EmbedButton() {
94
99
  const {
95
100
  initializeVoiceAgent,
96
101
  tokenDetails,
@@ -101,14 +106,13 @@ export function OnwidButton() {
101
106
  unmuteMic,
102
107
  connectionState,
103
108
  roomRef
104
- } = useVoiceAgent();
109
+ } = (0, _voiceagent.useVoiceAgent)();
105
110
  // State management
106
- const [configData, setConfigData] = useState(null);
107
- const [isOpen, setIsOpen] = useState(false);
108
- const [callDuration, setCallDuration] = useState(0);
109
- const timerRef = useRef(null);
110
- const lottieRef = useRef(null);
111
- console.log('roomRef', roomRef.current?.localParticipant);
111
+ const [configData, setConfigData] = (0, _react.useState)(null);
112
+ const [isOpen, setIsOpen] = (0, _react.useState)(false);
113
+ const [callDuration, setCallDuration] = (0, _react.useState)(0);
114
+ const timerRef = (0, _react.useRef)(null);
115
+ const lottieRef = (0, _react.useRef)(null);
112
116
 
113
117
  // Animation values
114
118
  const isPressed = useSharedValue(false);
@@ -124,9 +128,9 @@ export function OnwidButton() {
124
128
  const buttonWidth = useSharedValue(BUTTON_WIDTH);
125
129
  const buttonScale = useSharedValue(1);
126
130
  // Styles
127
- const styles = createOnwidButtonStyles(defaultStyles);
128
- const [isAutoOpen, setIsAutoOpen] = useState(false);
129
- useEffect(() => {
131
+ const styles = (0, _EmbedButtonStyle.createEmbedButtonStyles)(defaultStyles);
132
+ const [isAutoOpen, setIsAutoOpen] = (0, _react.useState)(false);
133
+ (0, _react.useEffect)(() => {
130
134
  const autoOpenTimer = setTimeout(() => {
131
135
  if (!isOpen) {
132
136
  console.log('autoOpenTimer', isOpen);
@@ -142,10 +146,10 @@ export function OnwidButton() {
142
146
  /**
143
147
  * Fetch agent configuration data
144
148
  */
145
- useEffect(() => {
149
+ (0, _react.useEffect)(() => {
146
150
  const fetchAgentData = async () => {
147
151
  try {
148
- const data = await getAgentData('@config_data');
152
+ const data = await (0, _storeKey.getAgentData)('@config_data');
149
153
  setConfigData(data?.ui_config);
150
154
  } catch (error) {
151
155
  console.error('Error retrieving agent data:', error);
@@ -157,7 +161,7 @@ export function OnwidButton() {
157
161
  /**
158
162
  * Set up a timer to track call duration when connected
159
163
  */
160
- useEffect(() => {
164
+ (0, _react.useEffect)(() => {
161
165
  if (connectionState === 'connected' && !timerRef.current) {
162
166
  timerRef.current = setInterval(() => {
163
167
  setCallDuration(prev => prev + 1);
@@ -182,7 +186,7 @@ export function OnwidButton() {
182
186
  /**
183
187
  * Handle menu animation and button width transitions
184
188
  */
185
- useEffect(() => {
189
+ (0, _react.useEffect)(() => {
186
190
  menuAnimation.value = withTiming(isOpen ? 0.8 : 0, {
187
191
  duration: 300
188
192
  });
@@ -190,7 +194,7 @@ export function OnwidButton() {
190
194
  }, [isOpen, menuAnimation, buttonWidth]);
191
195
 
192
196
  // Add breathing animation when button is closed but isAutoOpen is true
193
- useEffect(() => {
197
+ (0, _react.useEffect)(() => {
194
198
  if (!isOpen && isAutoOpen) {
195
199
  // Start breathing animation with faster speed
196
200
  buttonScale.value = withRepeat(withSequence(withTiming(1.1, {
@@ -254,7 +258,7 @@ export function OnwidButton() {
254
258
  /**
255
259
  * Pan gesture handler for drag functionality
256
260
  */
257
- const gesture = Gesture.Pan().onBegin(() => {
261
+ const gesture = _reactNativeGestureHandler.Gesture.Pan().onBegin(() => {
258
262
  isPressed.value = true;
259
263
  if (isAutoOpen) {
260
264
  runOnJS(setIsAutoOpen)(false);
@@ -296,13 +300,13 @@ export function OnwidButton() {
296
300
  * Render the button icon/animation
297
301
  */
298
302
 
299
- const remoteSource = useMemo(() => ({
303
+ const remoteSource = (0, _react.useMemo)(() => ({
300
304
  uri: configData?.icon_animation || AMPLIFY_ANIMATION
301
305
  }), [configData?.icon_animation]);
302
306
  const renderIcon = () => {
303
307
  // When isAutoOpen is true, we don't play the Lottie animation
304
- return /*#__PURE__*/_jsx(View, {
305
- children: /*#__PURE__*/_jsx(LottieView, {
308
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
309
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_lottieReactNative.default, {
306
310
  ref: lottieRef,
307
311
  source: remoteSource,
308
312
  autoPlay: true,
@@ -351,9 +355,9 @@ export function OnwidButton() {
351
355
  }
352
356
  };
353
357
  if (!configData) return null;
354
- return /*#__PURE__*/_jsxs(View, {
358
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
355
359
  style: styles.container,
356
- children: [isAutoOpen && !isOpen && /*#__PURE__*/_jsx(Animated.View, {
360
+ children: [isAutoOpen && !isOpen && /*#__PURE__*/(0, _jsxRuntime.jsx)(Animated.View, {
357
361
  style: [animatedTextStyles, {
358
362
  position: 'absolute',
359
363
  borderRadius: 5,
@@ -363,7 +367,7 @@ export function OnwidButton() {
363
367
  bottom: BUTTON_HEIGHT + 40
364
368
  // right: Math.abs(offset.value.x) + BUTTON_WIDTH + 0,
365
369
  }],
366
- children: /*#__PURE__*/_jsx(Text, {
370
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
367
371
  style: {
368
372
  color: 'white',
369
373
  fontSize: 10,
@@ -371,13 +375,13 @@ export function OnwidButton() {
371
375
  },
372
376
  children: configData?.popup_description || 'Revrag'
373
377
  })
374
- }), /*#__PURE__*/_jsx(GestureDetector, {
378
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector, {
375
379
  gesture: gesture,
376
- children: /*#__PURE__*/_jsx(Animated.View, {
380
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Animated.View, {
377
381
  style: [styles.button, animatedStyles, styles.buttonContent, {
378
382
  pointerEvents: 'auto'
379
383
  }],
380
- children: /*#__PURE__*/_jsxs(LinearGradient, {
384
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNativeLinearGradient.default, {
381
385
  colors: configData?.gradient || GRADIENT_COLORS,
382
386
  start: {
383
387
  x: 0,
@@ -400,25 +404,25 @@ export function OnwidButton() {
400
404
  x: 0.5,
401
405
  y: 0.5
402
406
  },
403
- children: [tokenDetails?.token && /*#__PURE__*/_jsx(Voice, {
407
+ children: [tokenDetails?.token && /*#__PURE__*/(0, _jsxRuntime.jsx)(_EmbedVoice.default, {
404
408
  url: tokenDetails?.server_url,
405
409
  token: tokenDetails?.token,
406
410
  onDisconnected: handleEndCall,
407
411
  roomRef: roomRef,
408
412
  onConnected: handleConnected
409
- }), /*#__PURE__*/_jsx(View, {
413
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
410
414
  style: [styles.rowContainer, {
411
415
  flexShrink: 0,
412
416
  width: BUTTON_WIDTH,
413
417
  padding: 0,
414
418
  margin: 0
415
419
  }],
416
- children: /*#__PURE__*/_jsx(TouchableOpacity, {
420
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
417
421
  onPress: handlePress,
418
422
  style: styles.pressable,
419
423
  children: renderIcon()
420
424
  })
421
- }), isOpen && /*#__PURE__*/_jsxs(View, {
425
+ }), isOpen && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
422
426
  style: {
423
427
  flex: 1,
424
428
  flexDirection: 'row',
@@ -426,7 +430,7 @@ export function OnwidButton() {
426
430
  marginLeft: 0,
427
431
  marginRight: 0
428
432
  },
429
- children: [/*#__PURE__*/_jsxs(View, {
433
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
430
434
  style: {
431
435
  flex: 1,
432
436
  justifyContent: 'center',
@@ -434,30 +438,30 @@ export function OnwidButton() {
434
438
  paddingLeft: 8,
435
439
  paddingRight: 4
436
440
  },
437
- children: [/*#__PURE__*/_jsx(Text, {
441
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
438
442
  style: [styles.agentNameText, {
439
443
  flexShrink: 1,
440
444
  textAlign: 'left'
441
445
  }],
442
446
  children: configData?.agent_name || 'Revrag'
443
- }), /*#__PURE__*/_jsx(Text, {
447
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
444
448
  style: [styles.statusText, {
445
449
  flexShrink: 1,
446
450
  textAlign: 'left'
447
451
  }],
448
452
  children: getStatusText()
449
453
  })]
450
- }), /*#__PURE__*/_jsx(View, {
454
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
451
455
  style: {
452
456
  flex: 1,
453
457
  justifyContent: 'center',
454
458
  alignItems: 'center',
455
459
  paddingHorizontal: 4
456
460
  },
457
- children: /*#__PURE__*/_jsx(WaveformVisualizer, {
461
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_EmbedAudioWave.WaveformVisualizer, {
458
462
  roomRef: roomRef
459
463
  })
460
- }), /*#__PURE__*/_jsxs(View, {
464
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
461
465
  style: {
462
466
  flex: 1,
463
467
  justifyContent: 'center',
@@ -465,28 +469,28 @@ export function OnwidButton() {
465
469
  paddingLeft: 4,
466
470
  paddingRight: 8
467
471
  },
468
- children: [!tokenDetails?.token && /*#__PURE__*/_jsx(TouchableOpacity, {
472
+ children: [!tokenDetails?.token && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
469
473
  onPress: handleStartCall,
470
474
  style: styles.startCallButton,
471
- children: /*#__PURE__*/_jsx(Text, {
475
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
472
476
  style: styles.startCallText,
473
477
  children: configData?.start_call_text || 'Start Call'
474
478
  })
475
- }), tokenDetails?.token && /*#__PURE__*/_jsxs(View, {
479
+ }), tokenDetails?.token && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
476
480
  style: [styles.buttonContainer],
477
- children: [/*#__PURE__*/_jsx(TouchableOpacity, {
481
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
478
482
  style: styles.muteButton,
479
483
  onPress: handleMicToggle,
480
- children: /*#__PURE__*/_jsx(Image, {
484
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Image, {
481
485
  source: {
482
486
  uri: isMicMuted ? MIC_OFF_ICON : MIC_ON_ICON
483
487
  },
484
488
  style: styles.buttonImage
485
489
  })
486
- }), /*#__PURE__*/_jsx(TouchableOpacity, {
490
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
487
491
  onPress: handleEndCall,
488
492
  style: styles.endCallButton,
489
- children: /*#__PURE__*/_jsx(Image, {
493
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Image, {
490
494
  source: {
491
495
  uri: END_CALL_ICON
492
496
  },
@@ -503,5 +507,5 @@ export function OnwidButton() {
503
507
  }
504
508
 
505
509
  // Export default for easier imports
506
- export default OnwidButton;
507
- //# sourceMappingURL=OnwidButton.js.map
510
+ var _default = exports.default = EmbedButton;
511
+ //# sourceMappingURL=EmbedButton.js.map