UNPKG

@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

90 lines (78 loc) 2.82 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.parseDelayMs = exports.formatDuration = exports.clamp = exports.calculateMaxY = exports.calculateMaxX = exports.SCREEN_WIDTH = exports.SCREEN_HEIGHT = exports.ICON_URLS = exports.DEFAULT_POPUP_DELAY_MS = exports.DEFAULT_GRADIENT_COLORS = exports.BUTTON_DIMENSIONS = void 0; var _reactNative = require("react-native"); /** * @file EmbedButton.helpers.ts * @description Helper functions and utilities for the EmbedButton component */ // ==================== CONSTANTS ==================== const { width: SCREEN_WIDTH, height: SCREEN_HEIGHT } = _reactNative.Dimensions.get('window'); exports.SCREEN_HEIGHT = SCREEN_HEIGHT; exports.SCREEN_WIDTH = SCREEN_WIDTH; const BUTTON_DIMENSIONS = exports.BUTTON_DIMENSIONS = { WIDTH: 60, HEIGHT: 60, EXPANDED_WIDTH: SCREEN_WIDTH * 0.9 }; const ICON_URLS = exports.ICON_URLS = { MIC_ON: 'https://revrag-dev.s3.ap-south-1.amazonaws.com/Avatars/Mute+button.png', MIC_OFF: 'https://revrag-dev.s3.ap-south-1.amazonaws.com/Avatars/unmute.png', END_CALL: 'https://revrag-dev.s3.ap-south-1.amazonaws.com/Avatars/end+button.png', AMPLIFY_ANIMATION: 'https://revrag-dev.s3.ap-south-1.amazonaws.com/Avatars/amplify.json' }; const DEFAULT_GRADIENT_COLORS = exports.DEFAULT_GRADIENT_COLORS = ['#1E0844', '#B391F3']; const DEFAULT_POPUP_DELAY_MS = exports.DEFAULT_POPUP_DELAY_MS = 15000; // ==================== TYPES ==================== // ==================== HELPER FUNCTIONS ==================== /** * Safely parse delay value to ensure it's a valid number */ const parseDelayMs = delay => { if (typeof delay === 'number') { return delay; } const parsed = Number(delay); return Number.isFinite(parsed) ? parsed : DEFAULT_POPUP_DELAY_MS; }; /** * Format seconds to MM:SS format */ exports.parseDelayMs = parseDelayMs; const formatDuration = seconds => { const minutes = Math.floor(seconds / 60); const remainingSeconds = seconds % 60; return `${minutes.toString().padStart(2, '0')}:${remainingSeconds.toString().padStart(2, '0')}`; }; /** * Calculate the max X position for button drag constraints */ exports.formatDuration = formatDuration; const calculateMaxX = isOpen => { 'worklet'; const width = isOpen ? BUTTON_DIMENSIONS.EXPANDED_WIDTH : BUTTON_DIMENSIONS.WIDTH; return SCREEN_WIDTH - width - 35; }; /** * Calculate the max Y position for button drag constraints */ exports.calculateMaxX = calculateMaxX; const calculateMaxY = () => { 'worklet'; return SCREEN_HEIGHT - 150; }; /** * Clamp a value between a min and max */ exports.calculateMaxY = calculateMaxY; const clamp = (value, min, max) => { 'worklet'; return Math.min(Math.max(value, min), max); }; exports.clamp = clamp; //# sourceMappingURL=EmbedButton.helpers.js.map