@revrag-ai/embed-react-native 1.0.6 → 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.
- package/LICENSE +1 -1
- package/README.md +13 -382
- package/android/CMakeLists.txt +15 -0
- package/android/build.gradle +77 -25
- package/android/cpp-adapter.cpp +8 -0
- package/android/generated/java/com/revragai/embedreactnative/NativeEmbedReactNativeSpec.java +37 -0
- package/android/generated/jni/CMakeLists.txt +49 -0
- package/android/generated/jni/RNEmbedReactNativeSpec-generated.cpp +32 -0
- package/android/generated/jni/RNEmbedReactNativeSpec.h +31 -0
- package/android/generated/jni/react/renderer/components/RNEmbedReactNativeSpec/RNEmbedReactNativeSpecJSI-generated.cpp +28 -0
- package/android/generated/jni/react/renderer/components/RNEmbedReactNativeSpec/RNEmbedReactNativeSpecJSI.h +67 -0
- package/android/gradle.properties +5 -5
- package/cpp/revrag-ai-embed-react-native.cpp +7 -0
- package/cpp/revrag-ai-embed-react-native.h +8 -0
- package/ios/EmbedReactNative.h +9 -0
- package/ios/{Onwid.mm → EmbedReactNative.mm} +4 -4
- package/ios/generated/RNEmbedReactNativeSpec/RNEmbedReactNativeSpec-generated.mm +29 -0
- package/ios/generated/RNEmbedReactNativeSpec/RNEmbedReactNativeSpec.h +50 -0
- package/ios/generated/RNEmbedReactNativeSpecJSI-generated.cpp +28 -0
- package/ios/generated/RNEmbedReactNativeSpecJSI.h +67 -0
- package/lib/commonjs/NativeEmbedReactNative.js +9 -0
- package/{dist/commonjs/onwidApi → lib/commonjs/api}/api.js +84 -13
- package/lib/commonjs/api/types/embed.api.types.js +2 -0
- package/{dist/module/component/audiowave.js → lib/commonjs/components/Embed/EmbedAudioWave.js} +21 -17
- package/{dist/module/component/OnwidButton.js → lib/commonjs/components/Embed/EmbedButton.js} +65 -61
- package/{dist/module/component/voice.js → lib/commonjs/components/Embed/EmbedVoice.js} +18 -14
- package/{dist/commonjs/style/onwidButton.style.js → lib/commonjs/components/styles/EmbedButton.style.js} +14 -9
- package/{dist/module/Event/onwid.js → lib/commonjs/events/embed.event.js} +14 -10
- package/{dist → lib}/commonjs/hooks/initialize.js +18 -12
- package/{dist/commonjs/hooks/initializelivekit.js → lib/commonjs/hooks/initialize.livekit.js} +8 -5
- package/lib/commonjs/hooks/types/voiceAgent.types.js +6 -0
- package/{dist/module/hooks/voiceAgent.js → lib/commonjs/hooks/voiceagent.js} +36 -31
- package/lib/commonjs/index.js +34 -0
- package/{dist/module/index.d.js → lib/commonjs/index.types.js} +7 -7
- package/lib/commonjs/store/store.key.js +46 -0
- package/{dist/module/utils/reanimatedHelpers.js → lib/commonjs/utils/reanimated.helper.js} +23 -17
- package/lib/module/NativeEmbedReactNative.js +5 -0
- package/{dist/module/onwidApi → lib/module/api}/api.js +67 -4
- package/lib/module/api/types/embed.api.types.js +2 -0
- package/{dist/commonjs/component/audiowave.js → lib/module/components/Embed/EmbedAudioWave.js} +2 -3
- package/{dist/commonjs/component/OnwidButton.js → lib/module/components/Embed/EmbedButton.js} +10 -11
- package/{dist/commonjs/component/voice.js → lib/module/components/Embed/EmbedVoice.js} +1 -1
- package/{dist/module/style/onwidButton.style.js → lib/module/components/styles/EmbedButton.style.js} +3 -3
- package/{dist/commonjs/Event/onwid.js → lib/module/events/embed.event.js} +6 -6
- package/{dist → lib}/module/hooks/initialize.js +3 -3
- package/{dist/module/hooks/initializelivekit.js → lib/module/hooks/initialize.livekit.js} +1 -1
- package/{dist/commonjs/hooks/voiceAgent.js → lib/module/hooks/voiceagent.js} +4 -4
- package/lib/module/index.js +7 -0
- package/{dist/commonjs/index.d.js → lib/module/index.types.js} +2 -1
- package/{dist/commonjs/utils/reanimatedHelpers.js → lib/module/utils/reanimated.helper.js} +14 -14
- package/lib/typescript/module/package.json +1 -0
- package/package.json +67 -33
- package/react-native.config.js +8 -14
- package/revrag-ai-embed-react-native.podspec +41 -0
- package/Onwid.podspec +0 -20
- package/dist/commonjs/NativeOnwid.js +0 -5
- package/dist/commonjs/button.json +0 -1
- package/dist/commonjs/index.js +0 -34
- package/dist/commonjs/onwidApi/api.types.js +0 -2
- package/dist/commonjs/utils/utils.js +0 -2
- package/dist/module/NativeOnwid.js +0 -5
- package/dist/module/button.json +0 -1
- package/dist/module/hooks/voiceAgent.types.js +0 -4
- package/dist/module/index.js +0 -34
- package/dist/module/onwidApi/api.types.js +0 -2
- package/dist/module/store.key.js +0 -38
- package/dist/module/utils/utils.js +0 -2
- package/dist/typescript/Event/onwid.d.ts +0 -14
- package/dist/typescript/NativeOnwid.d.ts +0 -7
- package/dist/typescript/component/OnwidButton.d.ts +0 -29
- package/dist/typescript/component/audiowave.d.ts +0 -7
- package/dist/typescript/component/voice.d.ts +0 -16
- package/dist/typescript/hooks/initialize.d.ts +0 -3
- package/dist/typescript/hooks/initialize.types.d.ts +0 -6
- package/dist/typescript/hooks/initializelivekit.d.ts +0 -4
- package/dist/typescript/hooks/voiceAgent.d.ts +0 -3
- package/dist/typescript/hooks/voiceAgent.types.d.ts +0 -17
- package/dist/typescript/index.d.ts +0 -27
- package/dist/typescript/onwidApi/api.d.ts +0 -54
- package/dist/typescript/onwidApi/api.types.d.ts +0 -22
- package/dist/typescript/store.key.d.ts +0 -4
- package/dist/typescript/style/onwidButton.style.d.ts +0 -99
- package/dist/typescript/utils/reanimatedHelpers.d.ts +0 -30
- package/dist/typescript/utils/utils.d.ts +0 -1
- package/ios/Onwid.h +0 -5
- package/scripts/verify-setup.js +0 -90
- /package/{dist/commonjs/hooks → lib/commonjs/hooks/types}/initialize.types.js +0 -0
- /package/{dist/module/hooks → lib/module/hooks/types}/initialize.types.js +0 -0
- /package/{dist/commonjs/hooks → lib/module/hooks/types}/voiceAgent.types.js +0 -0
- /package/{dist/commonjs → lib/module/store}/store.key.js +0 -0
- /package/{dist → lib/typescript}/commonjs/package.json +0 -0
package/{dist/module/component/audiowave.js → lib/commonjs/components/Embed/EmbedAudioWave.js}
RENAMED
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
|
|
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__*/
|
|
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__*/
|
|
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
|
-
|
|
156
|
+
exports.WaveformVisualizer = WaveformVisualizer;
|
|
157
|
+
//# sourceMappingURL=EmbedAudioWave.js.map
|
package/{dist/module/component/OnwidButton.js → lib/commonjs/components/Embed/EmbedButton.js}
RENAMED
|
@@ -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
|
-
|
|
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 =
|
|
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__*/
|
|
305
|
-
children: /*#__PURE__*/
|
|
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__*/
|
|
358
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
355
359
|
style: styles.container,
|
|
356
|
-
children: [isAutoOpen && !isOpen && /*#__PURE__*/
|
|
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__*/
|
|
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__*/
|
|
378
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector, {
|
|
375
379
|
gesture: gesture,
|
|
376
|
-
children: /*#__PURE__*/
|
|
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__*/
|
|
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__*/
|
|
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__*/
|
|
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__*/
|
|
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__*/
|
|
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__*/
|
|
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__*/
|
|
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__*/
|
|
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__*/
|
|
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__*/
|
|
461
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_EmbedAudioWave.WaveformVisualizer, {
|
|
458
462
|
roomRef: roomRef
|
|
459
463
|
})
|
|
460
|
-
}), /*#__PURE__*/
|
|
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__*/
|
|
472
|
+
children: [!tokenDetails?.token && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
|
|
469
473
|
onPress: handleStartCall,
|
|
470
474
|
style: styles.startCallButton,
|
|
471
|
-
children: /*#__PURE__*/
|
|
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__*/
|
|
479
|
+
}), tokenDetails?.token && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
476
480
|
style: [styles.buttonContainer],
|
|
477
|
-
children: [/*#__PURE__*/
|
|
481
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
|
|
478
482
|
style: styles.muteButton,
|
|
479
483
|
onPress: handleMicToggle,
|
|
480
|
-
children: /*#__PURE__*/
|
|
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__*/
|
|
490
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
|
|
487
491
|
onPress: handleEndCall,
|
|
488
492
|
style: styles.endCallButton,
|
|
489
|
-
children: /*#__PURE__*/
|
|
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
|
-
|
|
507
|
-
//# sourceMappingURL=
|
|
510
|
+
var _default = exports.default = EmbedButton;
|
|
511
|
+
//# sourceMappingURL=EmbedButton.js.map
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _reactNative = require("@livekit/react-native");
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
6
10
|
// export interface VoiceProps {
|
|
7
11
|
// url: string;
|
|
8
12
|
// token: string;
|
|
9
13
|
// onDisconnected: (data: string) => void;
|
|
10
14
|
// onConnected: (data: string) => void;
|
|
11
15
|
// }
|
|
12
|
-
|
|
16
|
+
|
|
13
17
|
// Track audio session state globally to prevent multiple starts/stops
|
|
14
18
|
let audioSessionActive = false;
|
|
15
19
|
let audioSessionStarting = false;
|
|
@@ -25,9 +29,9 @@ const Voice = props => {
|
|
|
25
29
|
onConnected,
|
|
26
30
|
roomRef
|
|
27
31
|
} = props;
|
|
28
|
-
const [audioSessionStarted, setAudioSessionStarted] = useState(audioSessionActive);
|
|
29
|
-
const mountedRef = useRef(true);
|
|
30
|
-
const connectedRef = useRef(false);
|
|
32
|
+
const [audioSessionStarted, setAudioSessionStarted] = (0, _react.useState)(audioSessionActive);
|
|
33
|
+
const mountedRef = (0, _react.useRef)(true);
|
|
34
|
+
const connectedRef = (0, _react.useRef)(false);
|
|
31
35
|
|
|
32
36
|
// Start audio session safely - prevent multiple simultaneous starts
|
|
33
37
|
const startAudioSession = async () => {
|
|
@@ -38,7 +42,7 @@ const Voice = props => {
|
|
|
38
42
|
try {
|
|
39
43
|
audioSessionStarting = true;
|
|
40
44
|
console.log('Starting audio session');
|
|
41
|
-
await AudioSession.startAudioSession();
|
|
45
|
+
await _reactNative.AudioSession.startAudioSession();
|
|
42
46
|
audioSessionActive = true;
|
|
43
47
|
if (mountedRef.current) {
|
|
44
48
|
setAudioSessionStarted(true);
|
|
@@ -59,7 +63,7 @@ const Voice = props => {
|
|
|
59
63
|
try {
|
|
60
64
|
audioSessionStopping = true;
|
|
61
65
|
console.log('Stopping audio session');
|
|
62
|
-
await AudioSession.stopAudioSession();
|
|
66
|
+
await _reactNative.AudioSession.stopAudioSession();
|
|
63
67
|
audioSessionActive = false;
|
|
64
68
|
} catch (err) {
|
|
65
69
|
console.error('Failed to stop audio session:', err);
|
|
@@ -69,7 +73,7 @@ const Voice = props => {
|
|
|
69
73
|
};
|
|
70
74
|
|
|
71
75
|
// Setup audio session
|
|
72
|
-
useEffect(() => {
|
|
76
|
+
(0, _react.useEffect)(() => {
|
|
73
77
|
mountedRef.current = true;
|
|
74
78
|
startAudioSession();
|
|
75
79
|
return () => {
|
|
@@ -86,7 +90,7 @@ const Voice = props => {
|
|
|
86
90
|
}, []);
|
|
87
91
|
|
|
88
92
|
// Track connection state changes to avoid unmounting while connected
|
|
89
|
-
useEffect(() => {
|
|
93
|
+
(0, _react.useEffect)(() => {
|
|
90
94
|
if (token) {
|
|
91
95
|
activeConnectionToken = token;
|
|
92
96
|
}
|
|
@@ -105,7 +109,7 @@ const Voice = props => {
|
|
|
105
109
|
|
|
106
110
|
// IMPORTANT: Never return empty fragment when connected!
|
|
107
111
|
// Instead, always render the LiveKitRoom component to maintain the connection
|
|
108
|
-
return /*#__PURE__*/
|
|
112
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.LiveKitRoom, {
|
|
109
113
|
serverUrl: url,
|
|
110
114
|
token: token,
|
|
111
115
|
screen: false,
|
|
@@ -123,5 +127,5 @@ const Voice = props => {
|
|
|
123
127
|
}
|
|
124
128
|
});
|
|
125
129
|
};
|
|
126
|
-
|
|
127
|
-
//# sourceMappingURL=
|
|
130
|
+
var _default = exports.default = Voice;
|
|
131
|
+
//# sourceMappingURL=EmbedVoice.js.map
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.onwidButtonStyles = exports.createEmbedButtonStyles = exports.EXPANDED_WIDTH = exports.BUTTON_WIDTH = exports.BUTTON_HEIGHT = void 0;
|
|
7
|
+
var _reactNative = require("react-native");
|
|
4
8
|
const {
|
|
5
9
|
width: SCREEN_WIDTH
|
|
6
|
-
} = Dimensions.get('window');
|
|
10
|
+
} = _reactNative.Dimensions.get('window');
|
|
7
11
|
|
|
8
12
|
// Calculate dynamic dimensions based on screen size
|
|
9
13
|
const calculateDimensions = () => {
|
|
@@ -26,10 +30,10 @@ const calculateDimensions = () => {
|
|
|
26
30
|
};
|
|
27
31
|
};
|
|
28
32
|
const dimensions = calculateDimensions();
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
+
const BUTTON_WIDTH = exports.BUTTON_WIDTH = dimensions.BUTTON_WIDTH;
|
|
34
|
+
const EXPANDED_WIDTH = exports.EXPANDED_WIDTH = dimensions.EXPANDED_WIDTH;
|
|
35
|
+
const BUTTON_HEIGHT = exports.BUTTON_HEIGHT = dimensions.BUTTON_HEIGHT;
|
|
36
|
+
const createEmbedButtonStyles = customStyles => {
|
|
33
37
|
const {
|
|
34
38
|
buttonWidth = BUTTON_WIDTH,
|
|
35
39
|
buttonHeight = BUTTON_HEIGHT,
|
|
@@ -38,7 +42,7 @@ export const createOnwidButtonStyles = customStyles => {
|
|
|
38
42
|
marginBottom = dimensions.SPACING.LARGE,
|
|
39
43
|
spacing = dimensions.SPACING
|
|
40
44
|
} = customStyles || {};
|
|
41
|
-
return StyleSheet.create({
|
|
45
|
+
return _reactNative.StyleSheet.create({
|
|
42
46
|
container: {
|
|
43
47
|
position: 'absolute',
|
|
44
48
|
bottom: 0,
|
|
@@ -239,5 +243,6 @@ export const createOnwidButtonStyles = customStyles => {
|
|
|
239
243
|
};
|
|
240
244
|
|
|
241
245
|
// Default styles export with dynamic dimensions
|
|
242
|
-
|
|
243
|
-
|
|
246
|
+
exports.createEmbedButtonStyles = createEmbedButtonStyles;
|
|
247
|
+
const onwidButtonStyles = exports.onwidButtonStyles = createEmbedButtonStyles();
|
|
248
|
+
//# sourceMappingURL=EmbedButton.style.js.map
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.EventKeys = void 0;
|
|
7
|
+
var _storeKey = require("../store/store.key.js");
|
|
8
|
+
var _api = require("../api/api.js");
|
|
5
9
|
// Predefined event keys
|
|
6
|
-
|
|
10
|
+
let EventKeys = exports.EventKeys = /*#__PURE__*/function (EventKeys) {
|
|
7
11
|
EventKeys["USER_DATA"] = "user_data";
|
|
8
12
|
EventKeys["SCREEN_STATE"] = "state_data";
|
|
9
13
|
return EventKeys;
|
|
10
14
|
}({});
|
|
11
|
-
class
|
|
15
|
+
class Embed {
|
|
12
16
|
events = {};
|
|
13
17
|
|
|
14
18
|
// Automatically adds a default listener if none exists
|
|
@@ -26,7 +30,7 @@ class OnWid {
|
|
|
26
30
|
}
|
|
27
31
|
const key = eventKey;
|
|
28
32
|
if (key !== EventKeys.USER_DATA) {
|
|
29
|
-
const userIdentity = await getAgentData(EventKeys.USER_DATA);
|
|
33
|
+
const userIdentity = await (0, _storeKey.getAgentData)(EventKeys.USER_DATA);
|
|
30
34
|
if (userIdentity) {
|
|
31
35
|
data.app_user_id = userIdentity.app_user_id;
|
|
32
36
|
} else {
|
|
@@ -39,7 +43,7 @@ class OnWid {
|
|
|
39
43
|
console.log('response,updateUserDatniuioioioa');
|
|
40
44
|
// Trigger API call
|
|
41
45
|
try {
|
|
42
|
-
const apiService = APIService.getInstance();
|
|
46
|
+
const apiService = _api.APIService.getInstance();
|
|
43
47
|
const response = await apiService.updateUserData({
|
|
44
48
|
eventKey: key,
|
|
45
49
|
data
|
|
@@ -48,7 +52,7 @@ class OnWid {
|
|
|
48
52
|
if (!response.success) {
|
|
49
53
|
console.error('Failed to trigger API for event:', eventKey);
|
|
50
54
|
}
|
|
51
|
-
setAgentData(data, key);
|
|
55
|
+
(0, _storeKey.setAgentData)(data, key);
|
|
52
56
|
} catch (error) {
|
|
53
57
|
console.error('Error triggering API:', error);
|
|
54
58
|
}
|
|
@@ -65,6 +69,6 @@ class OnWid {
|
|
|
65
69
|
this.events[eventKey]?.push(callback);
|
|
66
70
|
}
|
|
67
71
|
}
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
//# sourceMappingURL=
|
|
72
|
+
const embed = new Embed();
|
|
73
|
+
var _default = exports.default = embed;
|
|
74
|
+
//# sourceMappingURL=embed.event.js.map
|