@revrag-ai/embed-react-native
Version:
A powerful React Native library for integrating AI-powered voice agents into mobile applications. Features real-time voice communication, intelligent speech processing, customizable UI components, and comprehensive event handling for building conversation
98 lines (88 loc) • 3.01 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.checkReanimatedSetup = checkReanimatedSetup;
exports.getReanimatedAPI = getReanimatedAPI;
exports.showReanimatedSetupError = showReanimatedSetupError;
/**
* @file reanimatedHelpers.ts
* @description Utility functions to handle react-native-reanimated configuration and provide fallbacks
*/
let reanimatedAPI;
/**
* Safely loads react-native-reanimated and provides fallbacks if not available
*/
function getReanimatedAPI() {
if (reanimatedAPI) {
return reanimatedAPI;
}
try {
const reanimated = require('react-native-reanimated');
// Check if makeMutable is available (this is what was causing the original error)
if (!reanimated.makeMutable) {
throw new Error('makeMutable not found - react-native-reanimated may not be properly configured');
}
reanimatedAPI = {
useSharedValue: reanimated.useSharedValue,
useAnimatedStyle: reanimated.useAnimatedStyle,
withTiming: reanimated.withTiming,
withSpring: reanimated.withSpring,
withRepeat: reanimated.withRepeat,
withSequence: reanimated.withSequence,
runOnJS: reanimated.runOnJS,
Easing: reanimated.Easing,
Animated: reanimated.default,
isAvailable: true
};
return reanimatedAPI;
} catch (error) {
console.warn('⚠️ react-native-reanimated is not properly installed or configured:', error);
console.warn('📚 Please follow the setup guide: https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/getting-started');
// Provide fallback implementations
const ReactNative = require('react-native');
const View = ReactNative?.View || ReactNative?.default?.View;
reanimatedAPI = {
useSharedValue: value => ({
value
}),
useAnimatedStyle: () => ({}),
withTiming: value => value,
withSpring: value => value,
withRepeat: value => value,
withSequence: (...args) => args[args.length - 1],
runOnJS: fn => fn,
Easing: {
inOut: easing => easing,
ease: t => t
},
Animated: View,
isAvailable: false
};
return reanimatedAPI;
}
}
/**
* Check if react-native-reanimated is properly configured
*/
function checkReanimatedSetup() {
const api = getReanimatedAPI();
return api.isAvailable;
}
/**
* Display a helpful error message if reanimated is not configured
*/
function showReanimatedSetupError() {
console.error(`
🚨 React Native Reanimated Setup Required
The OnwidButton component requires react-native-reanimated to be properly installed and configured.
Quick Fix:
1. Install: npm install react-native-reanimated
2. Add to babel.config.js:
plugins: ['react-native-reanimated/plugin']
3. Rebuild your app
For detailed setup instructions, visit:
https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/getting-started
`);
}
//# sourceMappingURL=reanimated.helper.js.map