@revrag-ai/embed-react-native 1.0.5 → 1.0.7

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 (94) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +13 -382
  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/lib/commonjs/api/api.js +256 -0
  23. package/lib/commonjs/api/types/embed.api.types.js +2 -0
  24. package/lib/commonjs/components/Embed/EmbedAudioWave.js +157 -0
  25. package/lib/commonjs/components/Embed/EmbedButton.js +511 -0
  26. package/lib/commonjs/components/Embed/EmbedVoice.js +131 -0
  27. package/lib/commonjs/components/styles/EmbedButton.style.js +248 -0
  28. package/lib/commonjs/events/embed.event.js +74 -0
  29. package/lib/commonjs/hooks/initialize.js +102 -0
  30. package/lib/commonjs/hooks/initialize.livekit.js +20 -0
  31. package/lib/commonjs/hooks/types/initialize.types.js +2 -0
  32. package/lib/commonjs/hooks/types/voiceAgent.types.js +6 -0
  33. package/lib/commonjs/hooks/voiceagent.js +358 -0
  34. package/lib/commonjs/index.js +34 -0
  35. package/lib/commonjs/index.types.js +22 -0
  36. package/lib/commonjs/store/store.key.js +46 -0
  37. package/lib/commonjs/utils/reanimated.helper.js +100 -0
  38. package/lib/module/NativeEmbedReactNative.js +5 -0
  39. package/lib/module/api/api.js +248 -0
  40. package/lib/module/api/types/embed.api.types.js +2 -0
  41. package/lib/module/components/Embed/EmbedAudioWave.js +152 -0
  42. package/lib/module/components/Embed/EmbedButton.js +506 -0
  43. package/lib/module/components/Embed/EmbedVoice.js +127 -0
  44. package/lib/module/components/styles/EmbedButton.style.js +243 -0
  45. package/lib/module/events/embed.event.js +70 -0
  46. package/lib/module/hooks/initialize.js +79 -75
  47. package/lib/module/hooks/{initializelivekit.js → initialize.livekit.js} +7 -4
  48. package/lib/module/hooks/types/initialize.types.js +2 -0
  49. package/lib/module/hooks/types/voiceAgent.types.js +4 -0
  50. package/lib/module/hooks/voiceagent.js +353 -0
  51. package/lib/module/index.js +6 -60
  52. package/lib/module/index.types.js +23 -0
  53. package/lib/module/store/store.key.js +38 -0
  54. package/lib/module/utils/reanimated.helper.js +94 -0
  55. package/lib/typescript/commonjs/package.json +1 -0
  56. package/lib/typescript/module/package.json +1 -0
  57. package/package.json +69 -27
  58. package/react-native.config.js +8 -14
  59. package/revrag-ai-embed-react-native.podspec +41 -0
  60. package/Onwid.podspec +0 -20
  61. package/ios/Onwid.h +0 -5
  62. package/lib/index.d.ts +0 -77
  63. package/lib/module/Event/onwid.js +0 -74
  64. package/lib/module/NativeOnwid.js +0 -4
  65. package/lib/module/component/OnwidButton.js +0 -366
  66. package/lib/module/component/audiowave.js +0 -137
  67. package/lib/module/component/voice.js +0 -103
  68. package/lib/module/hooks/initialize.types.js +0 -2
  69. package/lib/module/hooks/voiceAgent.js +0 -334
  70. package/lib/module/hooks/voiceAgent.types.js +0 -2
  71. package/lib/module/onwidApi/api.js +0 -184
  72. package/lib/module/onwidApi/api.types.js +0 -2
  73. package/lib/module/store.key.js +0 -47
  74. package/lib/module/style/onwidButton.style.js +0 -230
  75. package/lib/module/utils/reanimatedHelpers.js +0 -87
  76. package/lib/module/utils/utils.js +0 -1
  77. package/lib/typescript/Event/onwid.d.ts +0 -13
  78. package/lib/typescript/NativeOnwid.d.ts +0 -6
  79. package/lib/typescript/component/OnwidButton.d.ts +0 -28
  80. package/lib/typescript/component/audiowave.d.ts +0 -6
  81. package/lib/typescript/component/voice.d.ts +0 -15
  82. package/lib/typescript/hooks/initialize.d.ts +0 -2
  83. package/lib/typescript/hooks/initialize.types.d.ts +0 -5
  84. package/lib/typescript/hooks/initializelivekit.d.ts +0 -3
  85. package/lib/typescript/hooks/voiceAgent.d.ts +0 -2
  86. package/lib/typescript/hooks/voiceAgent.types.d.ts +0 -16
  87. package/lib/typescript/index.d.ts +0 -27
  88. package/lib/typescript/onwidApi/api.d.ts +0 -53
  89. package/lib/typescript/onwidApi/api.types.d.ts +0 -21
  90. package/lib/typescript/store.key.d.ts +0 -3
  91. package/lib/typescript/style/onwidButton.style.d.ts +0 -98
  92. package/lib/typescript/utils/reanimatedHelpers.d.ts +0 -29
  93. package/lib/typescript/utils/utils.d.ts +0 -0
  94. package/scripts/verify-setup.js +0 -90
@@ -0,0 +1,358 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useVoiceAgent = void 0;
7
+ var _livekitClient = require("livekit-client");
8
+ var _react = require("react");
9
+ var _embedEvent = require("../events/embed.event.js");
10
+ var _api = require("../api/api.js");
11
+ var _storeKey = require("../store/store.key.js");
12
+ // Create a singleton instance of Room that persists across hook instances
13
+ // This ensures we don't create multiple Room instances that could conflict
14
+ let roomInstance = null;
15
+ let isConnecting = false;
16
+ let isDisconnecting = false;
17
+ let hasListeners = false;
18
+ let connectionAttempts = 0;
19
+ let stableConnectionTimerId = null;
20
+ const MAX_CONNECTION_ATTEMPTS = 3;
21
+ const STABLE_CONNECTION_TIMEOUT = 5000; // 5 seconds
22
+
23
+ // Create getters for the room instance
24
+ const getRoomInstance = () => {
25
+ if (!roomInstance) {
26
+ console.log('Creating new Room instance');
27
+ // Configure the room with the right options at creation time
28
+ roomInstance = new _livekitClient.Room({
29
+ adaptiveStream: true,
30
+ dynacast: true,
31
+ // Using the most stable configuration for React Native
32
+ publishDefaults: {
33
+ simulcast: false // Disable simulcast to reduce SDP complexity
34
+ }
35
+ });
36
+ }
37
+ return roomInstance;
38
+ };
39
+
40
+ // Reset connection attempt counter
41
+ const resetConnectionAttempts = () => {
42
+ connectionAttempts = 0;
43
+
44
+ // Clear any pending stable connection timer
45
+ if (stableConnectionTimerId) {
46
+ clearTimeout(stableConnectionTimerId);
47
+ stableConnectionTimerId = null;
48
+ }
49
+ };
50
+
51
+ // Cleanup function to reset the room state
52
+ const resetRoomState = () => {
53
+ if (roomInstance) {
54
+ try {
55
+ console.log('Resetting room state');
56
+ console.log('isDisconnecting', isDisconnecting);
57
+
58
+ // Only disconnect if currently connected
59
+ if (roomInstance.state !== _livekitClient.ConnectionState.Disconnected && !isDisconnecting) {
60
+ isDisconnecting = true;
61
+ roomInstance.disconnect().finally(() => {
62
+ isDisconnecting = false;
63
+ });
64
+ }
65
+
66
+ // Don't destroy the room instance, just reset its state
67
+ hasListeners = false;
68
+ resetConnectionAttempts();
69
+ } catch (e) {
70
+ console.error('Error resetting room state:', e);
71
+ }
72
+ }
73
+ };
74
+ const useVoiceAgent = () => {
75
+ const [isLoading, setIsLoading] = (0, _react.useState)(false);
76
+ const [error, setError] = (0, _react.useState)(null);
77
+ const [tokenDetails, setTokenDetails] = (0, _react.useState)(null);
78
+ const [isMicMuted, setIsMicMuted] = (0, _react.useState)(false);
79
+ const [connectionState, setConnectionState] = (0, _react.useState)(() => {
80
+ // Initialize with the current room state if it exists
81
+ const room = getRoomInstance();
82
+ return room ? room.state : _livekitClient.ConnectionState.Disconnected;
83
+ });
84
+ const [stableConnection, setStableConnection] = (0, _react.useState)(false);
85
+ console.log('ConnectionState_connected', connectionState
86
+ // tokenDetails?.token
87
+ );
88
+
89
+ // Setup event listeners for the room
90
+ const setupRoomListeners = () => {
91
+ if (hasListeners || !roomInstance) return;
92
+ console.log('Setting up room listeners');
93
+ const handleConnectionChange = state => {
94
+ console.log('Connection state changed:', state);
95
+ // Use a function to ensure we're setting with the latest state
96
+ setConnectionState(() => state);
97
+
98
+ // Handle connection state changes
99
+ if (state === _livekitClient.ConnectionState.Connected) {
100
+ // Reset connection attempts when connected successfully
101
+ resetConnectionAttempts();
102
+
103
+ // Set up a timer to mark the connection as stable after a few seconds
104
+ // This prevents immediate disconnections from being treated as stable
105
+ if (stableConnectionTimerId) {
106
+ clearTimeout(stableConnectionTimerId);
107
+ }
108
+ stableConnectionTimerId = setTimeout(() => {
109
+ console.log('Connection marked as stable');
110
+ setStableConnection(true);
111
+ }, STABLE_CONNECTION_TIMEOUT);
112
+ } else if (state === _livekitClient.ConnectionState.Disconnected) {
113
+ // Mark connection as unstable
114
+ setStableConnection(false);
115
+
116
+ // Clear any pending stable connection timer
117
+ if (stableConnectionTimerId) {
118
+ clearTimeout(stableConnectionTimerId);
119
+ stableConnectionTimerId = null;
120
+ }
121
+
122
+ // If disconnected unexpectedly and we have token details, don't automatically reconnect
123
+ // This prevents connection loops
124
+ if (tokenDetails && !isDisconnecting) {
125
+ console.log('Room disconnected unexpectedly - not auto-reconnecting');
126
+ }
127
+ }
128
+ };
129
+ const handleTrackSubscribed = track => {
130
+ if (track.kind === 'audio') {
131
+ track.setVolume(1.0);
132
+ }
133
+ };
134
+
135
+ // Handle participant disconnected - this could be helpful to detect server-side kicks
136
+ roomInstance.on('participantDisconnected', () => {
137
+ console.log('Participant disconnected from room');
138
+ });
139
+ roomInstance.on('connectionStateChanged', handleConnectionChange);
140
+ roomInstance.on('trackSubscribed', handleTrackSubscribed);
141
+
142
+ // Listen for SDP negotiation errors to handle them better
143
+ roomInstance.on('mediaDevicesError', e => {
144
+ console.log('Media devices error:', e.message);
145
+ });
146
+ hasListeners = true;
147
+ };
148
+
149
+ // Initialize room and listeners
150
+ (0, _react.useEffect)(() => {
151
+ const room = getRoomInstance();
152
+ setupRoomListeners();
153
+
154
+ // Sync local state with room state
155
+ setConnectionState(room.state);
156
+ return () => {
157
+ // Do NOT disconnect or destroy the room on component unmount
158
+ // This ensures the singleton persists across component lifecycle
159
+ // But we do want to update local state if the component is unmounted
160
+ if (!tokenDetails) {
161
+ setTokenDetails(null);
162
+ }
163
+ };
164
+ }, []);
165
+
166
+ // Connect to LiveKit when token is set
167
+ (0, _react.useEffect)(() => {
168
+ const room = getRoomInstance();
169
+ if (!tokenDetails || isConnecting) return;
170
+
171
+ // Always sync our state with the room's current state
172
+ setConnectionState(room.state);
173
+ const connectToRoom = async () => {
174
+ // Prevent multiple connection attempts
175
+ if (isConnecting) return;
176
+
177
+ // Limit connection attempts to prevent infinite loops
178
+ if (connectionAttempts >= MAX_CONNECTION_ATTEMPTS) {
179
+ console.log(`Maximum connection attempts (${MAX_CONNECTION_ATTEMPTS}) reached. Not trying again.`);
180
+ setError(`Failed to connect after ${MAX_CONNECTION_ATTEMPTS} attempts`);
181
+ return;
182
+ }
183
+ connectionAttempts++;
184
+ try {
185
+ isConnecting = true;
186
+ console.log(`Connecting to LiveKit room... (attempt ${connectionAttempts})`);
187
+
188
+ // Only attempt to connect if we're disconnected
189
+ if (room.state === _livekitClient.ConnectionState.Disconnected) {
190
+ // Update state before connection attempt
191
+ setConnectionState(_livekitClient.ConnectionState.Connecting);
192
+ await room.connect(tokenDetails.server_url, tokenDetails.token, {
193
+ autoSubscribe: true // Ensure we subscribe to tracks automatically
194
+ });
195
+
196
+ // Explicitly set to connected if connection was successful
197
+ setConnectionState(room.state);
198
+ console.log('Connected to LiveKit room');
199
+ } else if (room.state === _livekitClient.ConnectionState.Connected) {
200
+ console.log('Room is already connected');
201
+ // Ensure our state matches
202
+ setConnectionState(_livekitClient.ConnectionState.Connected);
203
+ } else {
204
+ console.log('Room is in transition state:', room.state);
205
+ // Sync our state with the room's current state
206
+ setConnectionState(room.state);
207
+ }
208
+ } catch (err) {
209
+ const message = err instanceof Error ? err.message : 'Failed to connect to room';
210
+ setError(message);
211
+ console.error('Connection error:', message);
212
+
213
+ // Sync state to disconnected if we failed to connect
214
+ setConnectionState(room.state);
215
+
216
+ // Don't keep retrying if we hit an SDP error
217
+ if (message.includes('SDP') || message.includes('sdp')) {
218
+ console.log('SDP error detected, will not retry automatically');
219
+ }
220
+ } finally {
221
+ isConnecting = false;
222
+ }
223
+ };
224
+ connectToRoom();
225
+
226
+ // No cleanup here - we don't want to disconnect when token changes or component unmounts
227
+ }, [tokenDetails]);
228
+
229
+ // Log connection status periodically for debugging
230
+ (0, _react.useEffect)(() => {
231
+ const debugInterval = setInterval(() => {
232
+ if (roomInstance) {
233
+ const state = roomInstance.state;
234
+ const participantCount = roomInstance.numParticipants;
235
+ console.log(`[DEBUG] Room state: ${state}, Participants: ${participantCount}, Stable: ${stableConnection}`);
236
+ }
237
+ }, 10000); // Every 10 seconds
238
+
239
+ return () => clearInterval(debugInterval);
240
+ }, [stableConnection]);
241
+
242
+ // Generate token and connect
243
+ const generateVoiceToken = async () => {
244
+ console.log('generateVoiceToken');
245
+
246
+ // Don't generate a new token if we're already connecting/connected
247
+ if (isConnecting || isLoading) {
248
+ console.log('Already connecting or loading, skipping token generation');
249
+ return;
250
+ }
251
+
252
+ // Reset connection attempts when starting fresh
253
+ resetConnectionAttempts();
254
+ setStableConnection(false);
255
+ const userData = await (0, _storeKey.getAgentData)(_embedEvent.EventKeys.USER_DATA);
256
+ setIsLoading(true);
257
+ setError(null);
258
+ console.log('userData', userData);
259
+ try {
260
+ const apiService = _api.APIService.getInstance();
261
+ const response = await apiService.getTokenDetails({
262
+ app_user_id: userData?.app_user_id,
263
+ call_type: 'EMBEDDED'
264
+ });
265
+ if (!response.data) throw new Error('No voice token found');
266
+
267
+ // Only set token details if we're not already connected
268
+ const room = getRoomInstance();
269
+ if (room.state !== _livekitClient.ConnectionState.Connected) {
270
+ setTokenDetails(response.data);
271
+ } else {
272
+ console.log('Room already connected, skipping token update');
273
+ }
274
+ } catch (err) {
275
+ const message = err instanceof Error ? err.message : 'Failed to generate voice token';
276
+ setError(message);
277
+ throw new Error(message);
278
+ } finally {
279
+ setIsLoading(false);
280
+ }
281
+ };
282
+
283
+ // End call
284
+ const endCall = async () => {
285
+ if (isDisconnecting) {
286
+ console.log('Already disconnecting, skipping');
287
+ return;
288
+ }
289
+ try {
290
+ console.log('Ending call');
291
+ isDisconnecting = true;
292
+ setTokenDetails(null);
293
+ setIsMicMuted(false);
294
+ resetConnectionAttempts();
295
+ setStableConnection(false);
296
+ const room = getRoomInstance();
297
+ if (room.state !== _livekitClient.ConnectionState.Disconnected) {
298
+ // Update state before disconnection
299
+ setConnectionState(_livekitClient.ConnectionState.Connecting);
300
+ await room.disconnect();
301
+
302
+ // Update state after disconnection
303
+ setConnectionState(_livekitClient.ConnectionState.Disconnected);
304
+ }
305
+ } catch (err) {
306
+ setError(err instanceof Error ? err.message : 'Failed to end call');
307
+ // Make sure state is correctly reflected even if there's an error
308
+ const room = getRoomInstance();
309
+ setConnectionState(room.state);
310
+ } finally {
311
+ isDisconnecting = false;
312
+ }
313
+ };
314
+
315
+ // Mute microphone
316
+ const muteMic = () => {
317
+ const room = getRoomInstance();
318
+ if (room.localParticipant) {
319
+ room.localParticipant.setMicrophoneEnabled(false);
320
+ setIsMicMuted(true);
321
+ console.log('Microphone muted');
322
+ }
323
+ };
324
+
325
+ // Unmute microphone
326
+ const unmuteMic = () => {
327
+ const room = getRoomInstance();
328
+ if (room.localParticipant) {
329
+ room.localParticipant.setMicrophoneEnabled(true);
330
+ setIsMicMuted(false);
331
+ console.log('Microphone unmuted');
332
+ }
333
+ };
334
+
335
+ // Clean up everything (use only when the app is shutting down)
336
+ const cleanup = () => {
337
+ endCall();
338
+ resetRoomState();
339
+ };
340
+ return {
341
+ initializeVoiceAgent: generateVoiceToken,
342
+ endCall,
343
+ muteMic,
344
+ unmuteMic,
345
+ isMicMuted,
346
+ connectionState,
347
+ room: getRoomInstance(),
348
+ tokenDetails,
349
+ isLoading,
350
+ error,
351
+ roomRef: {
352
+ current: getRoomInstance()
353
+ },
354
+ cleanup
355
+ };
356
+ };
357
+ exports.useVoiceAgent = useVoiceAgent;
358
+ //# sourceMappingURL=voiceagent.js.map
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "Embed", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _embedEvent.default;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "EmbedButton", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _EmbedButton.EmbedButton;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "EmbedEventKeys", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _embedEvent.EventKeys;
22
+ }
23
+ });
24
+ Object.defineProperty(exports, "useInitialize", {
25
+ enumerable: true,
26
+ get: function () {
27
+ return _initialize.useInitialize;
28
+ }
29
+ });
30
+ var _EmbedButton = require("./components/Embed/EmbedButton.js");
31
+ var _initialize = require("./hooks/initialize.js");
32
+ var _embedEvent = _interopRequireWildcard(require("./events/embed.event.js"));
33
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
34
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.EventKeys = void 0;
7
+ /* eslint-disable */
8
+ /**
9
+ * @file index.d.ts
10
+ * @description TypeScript declarations for the Onwid React Native library.
11
+ */
12
+ // Component declarations
13
+ // Hook type declarations
14
+ // Hook declarations
15
+ // API type declarations
16
+ // Event system declarations
17
+ let EventKeys = exports.EventKeys = /*#__PURE__*/function (EventKeys) {
18
+ EventKeys["USER_DATA"] = "user_data";
19
+ EventKeys["SCREEN_STATE"] = "state_data";
20
+ return EventKeys;
21
+ }({});
22
+ //# sourceMappingURL=index.types.js.map
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.setAgentData = exports.getAgentData = exports.deleteFromDetail = void 0;
7
+ var _asyncStorage = _interopRequireDefault(require("@react-native-async-storage/async-storage"));
8
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
+ const STORAGE_KEY = '@user_data';
10
+ const setAgentData = async (data, key = STORAGE_KEY) => {
11
+ try {
12
+ const jsonString = JSON.stringify(data);
13
+ await _asyncStorage.default.setItem(key, jsonString);
14
+ console.log('Data saved to storage successfully');
15
+ } catch (error) {
16
+ console.error('Storage save error:', error);
17
+ throw error; // Re-throw to allow caller to handle
18
+ }
19
+ };
20
+ exports.setAgentData = setAgentData;
21
+ const getAgentData = async (key = STORAGE_KEY) => {
22
+ try {
23
+ const jsonString = await _asyncStorage.default.getItem(key);
24
+ if (!jsonString) {
25
+ console.log('No data stored');
26
+ return null;
27
+ }
28
+ const data = JSON.parse(jsonString);
29
+ return data;
30
+ } catch (error) {
31
+ console.error('Storage fetch error:', error);
32
+ throw error; // Re-throw to allow caller to handle
33
+ }
34
+ };
35
+ exports.getAgentData = getAgentData;
36
+ const deleteFromDetail = async key => {
37
+ try {
38
+ await _asyncStorage.default.removeItem(key);
39
+ console.log('Storage data reset successfully');
40
+ } catch (error) {
41
+ console.error('Storage reset error:', error);
42
+ throw error; // Re-throw to allow caller to handle
43
+ }
44
+ };
45
+ exports.deleteFromDetail = deleteFromDetail;
46
+ //# sourceMappingURL=store.key.js.map
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.checkReanimatedSetup = checkReanimatedSetup;
7
+ exports.getReanimatedAPI = getReanimatedAPI;
8
+ exports.showReanimatedSetupError = showReanimatedSetupError;
9
+ /**
10
+ * @file reanimatedHelpers.ts
11
+ * @description Utility functions to handle react-native-reanimated configuration and provide fallbacks
12
+ */
13
+
14
+ let reanimatedAPI;
15
+
16
+ /**
17
+ * Safely loads react-native-reanimated and provides fallbacks if not available
18
+ */
19
+ function getReanimatedAPI() {
20
+ if (reanimatedAPI) {
21
+ return reanimatedAPI;
22
+ }
23
+ try {
24
+ const reanimated = require('react-native-reanimated');
25
+
26
+ // Check if makeMutable is available (this is what was causing the original error)
27
+ if (!reanimated.makeMutable) {
28
+ throw new Error('makeMutable not found - react-native-reanimated may not be properly configured');
29
+ }
30
+ reanimatedAPI = {
31
+ useSharedValue: reanimated.useSharedValue,
32
+ useAnimatedStyle: reanimated.useAnimatedStyle,
33
+ withTiming: reanimated.withTiming,
34
+ withSpring: reanimated.withSpring,
35
+ withRepeat: reanimated.withRepeat,
36
+ withSequence: reanimated.withSequence,
37
+ runOnJS: reanimated.runOnJS,
38
+ Easing: reanimated.Easing,
39
+ Animated: reanimated.default,
40
+ isAvailable: true
41
+ };
42
+ console.log('✅ react-native-reanimated loaded successfully');
43
+ return reanimatedAPI;
44
+ } catch (error) {
45
+ console.warn('⚠️ react-native-reanimated is not properly installed or configured:', error);
46
+ console.warn('📚 Please follow the setup guide: https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/getting-started');
47
+
48
+ // Provide fallback implementations
49
+ const {
50
+ View
51
+ } = require('react-native');
52
+ reanimatedAPI = {
53
+ useSharedValue: value => ({
54
+ value
55
+ }),
56
+ useAnimatedStyle: () => ({}),
57
+ withTiming: value => value,
58
+ withSpring: value => value,
59
+ withRepeat: value => value,
60
+ withSequence: (...args) => args[args.length - 1],
61
+ runOnJS: fn => fn,
62
+ Easing: {
63
+ inOut: easing => easing,
64
+ ease: t => t
65
+ },
66
+ Animated: View,
67
+ isAvailable: false
68
+ };
69
+ return reanimatedAPI;
70
+ }
71
+ }
72
+
73
+ /**
74
+ * Check if react-native-reanimated is properly configured
75
+ */
76
+ function checkReanimatedSetup() {
77
+ const api = getReanimatedAPI();
78
+ return api.isAvailable;
79
+ }
80
+
81
+ /**
82
+ * Display a helpful error message if reanimated is not configured
83
+ */
84
+ function showReanimatedSetupError() {
85
+ console.error(`
86
+ 🚨 React Native Reanimated Setup Required
87
+
88
+ The OnwidButton component requires react-native-reanimated to be properly installed and configured.
89
+
90
+ Quick Fix:
91
+ 1. Install: npm install react-native-reanimated
92
+ 2. Add to babel.config.js:
93
+ plugins: ['react-native-reanimated/plugin']
94
+ 3. Rebuild your app
95
+
96
+ For detailed setup instructions, visit:
97
+ https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/getting-started
98
+ `);
99
+ }
100
+ //# sourceMappingURL=reanimated.helper.js.map
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ import { TurboModuleRegistry } from 'react-native';
4
+ export default TurboModuleRegistry.getEnforcing('EmbedReactNative');
5
+ //# sourceMappingURL=NativeEmbedReactNative.js.map