@revrag-ai/embed-react-native 1.0.5
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 +20 -0
- package/Onwid.podspec +20 -0
- package/README.md +402 -0
- package/android/build.gradle +83 -0
- package/android/gradle.properties +5 -0
- package/ios/Onwid.h +5 -0
- package/ios/Onwid.mm +18 -0
- package/lib/index.d.ts +77 -0
- package/lib/module/Event/onwid.js +74 -0
- package/lib/module/NativeOnwid.js +4 -0
- package/lib/module/component/OnwidButton.js +366 -0
- package/lib/module/component/audiowave.js +137 -0
- package/lib/module/component/voice.js +103 -0
- package/lib/module/hooks/initialize.js +92 -0
- package/lib/module/hooks/initialize.types.js +2 -0
- package/lib/module/hooks/initializelivekit.js +14 -0
- package/lib/module/hooks/voiceAgent.js +334 -0
- package/lib/module/hooks/voiceAgent.types.js +2 -0
- package/lib/module/index.js +61 -0
- package/lib/module/onwidApi/api.js +184 -0
- package/lib/module/onwidApi/api.types.js +2 -0
- package/lib/module/store.key.js +47 -0
- package/lib/module/style/onwidButton.style.js +230 -0
- package/lib/module/utils/reanimatedHelpers.js +87 -0
- package/lib/module/utils/utils.js +1 -0
- package/lib/typescript/Event/onwid.d.ts +13 -0
- package/lib/typescript/NativeOnwid.d.ts +6 -0
- package/lib/typescript/component/OnwidButton.d.ts +28 -0
- package/lib/typescript/component/audiowave.d.ts +6 -0
- package/lib/typescript/component/voice.d.ts +15 -0
- package/lib/typescript/hooks/initialize.d.ts +2 -0
- package/lib/typescript/hooks/initialize.types.d.ts +5 -0
- package/lib/typescript/hooks/initializelivekit.d.ts +3 -0
- package/lib/typescript/hooks/voiceAgent.d.ts +2 -0
- package/lib/typescript/hooks/voiceAgent.types.d.ts +16 -0
- package/lib/typescript/index.d.ts +27 -0
- package/lib/typescript/onwidApi/api.d.ts +53 -0
- package/lib/typescript/onwidApi/api.types.d.ts +21 -0
- package/lib/typescript/store.key.d.ts +3 -0
- package/lib/typescript/style/onwidButton.style.d.ts +98 -0
- package/lib/typescript/utils/reanimatedHelpers.d.ts +29 -0
- package/lib/typescript/utils/utils.d.ts +0 -0
- package/package.json +208 -0
- package/react-native.config.js +19 -0
- package/scripts/verify-setup.js +90 -0
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getTokenDetails = exports.updateUserData = exports.registerOnInitialize = exports.initializeApi = exports.APIService = void 0;
|
|
4
|
+
const store_key_1 = require("../store.key");
|
|
5
|
+
/**
|
|
6
|
+
* APIService class that ensures proper initialization before API calls
|
|
7
|
+
*/
|
|
8
|
+
class APIService {
|
|
9
|
+
constructor() {
|
|
10
|
+
this.apiBaseUrl = null;
|
|
11
|
+
this.isInitialized = false;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Get singleton instance of APIService
|
|
15
|
+
*/
|
|
16
|
+
static getInstance() {
|
|
17
|
+
if (!APIService.instance) {
|
|
18
|
+
APIService.instance = new APIService();
|
|
19
|
+
}
|
|
20
|
+
return APIService.instance;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Initialize the API service with the base URL
|
|
24
|
+
*/
|
|
25
|
+
async initialize() {
|
|
26
|
+
if (this.isInitialized && this.apiBaseUrl) {
|
|
27
|
+
return; // Already initialized
|
|
28
|
+
}
|
|
29
|
+
const AgentData = await (0, store_key_1.getAgentData)();
|
|
30
|
+
console.log('AgentData', AgentData);
|
|
31
|
+
if (AgentData === null || AgentData === void 0 ? void 0 : AgentData.onwidUrl) {
|
|
32
|
+
this.apiBaseUrl = AgentData.onwidUrl;
|
|
33
|
+
this.isInitialized = true;
|
|
34
|
+
console.log('API_BASE_URL initialized:', this.apiBaseUrl);
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
throw new Error('API base URL not found in keychain');
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Ensure the service is initialized before making API calls
|
|
42
|
+
*/
|
|
43
|
+
async ensureInitialized() {
|
|
44
|
+
if (!this.isInitialized || !this.apiBaseUrl) {
|
|
45
|
+
await this.initialize();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Get headers with stored API key
|
|
50
|
+
*/
|
|
51
|
+
async getHeaders() {
|
|
52
|
+
const AgentData = await (0, store_key_1.getAgentData)();
|
|
53
|
+
if (!(AgentData === null || AgentData === void 0 ? void 0 : AgentData.apiKey)) {
|
|
54
|
+
throw new Error('API key not found in keychain');
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
'Content-Type': 'application/json',
|
|
58
|
+
'Authorization': `Bearer ${AgentData.apiKey}`,
|
|
59
|
+
'X-Revrag-Embedded-Key': AgentData.apiKey,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Register a new user/device on initialization
|
|
64
|
+
* @returns Promise with registration response
|
|
65
|
+
*/
|
|
66
|
+
async registerOnInitialize() {
|
|
67
|
+
try {
|
|
68
|
+
await this.ensureInitialized();
|
|
69
|
+
console.log('registerOnInitialize ApiData', this.apiBaseUrl);
|
|
70
|
+
const headers = await this.getHeaders();
|
|
71
|
+
const response = await fetch(`${this.apiBaseUrl}/embedded-agent/initialize`, {
|
|
72
|
+
method: 'GET',
|
|
73
|
+
headers: headers,
|
|
74
|
+
});
|
|
75
|
+
const data = await response.json();
|
|
76
|
+
console.log('dat config data after register', data);
|
|
77
|
+
await (0, store_key_1.setAgentData)(data, '@config_data');
|
|
78
|
+
if (!response.ok) {
|
|
79
|
+
console.log('registerOnInitialize error', data.error);
|
|
80
|
+
throw new Error(data.error || 'Registration failed');
|
|
81
|
+
}
|
|
82
|
+
return {
|
|
83
|
+
success: true,
|
|
84
|
+
data: data,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
console.log('registerOnInitialize error', error);
|
|
89
|
+
return {
|
|
90
|
+
success: false,
|
|
91
|
+
error: error instanceof Error ? error.message : 'Unknown error occurred',
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Update user data
|
|
97
|
+
* @param params Update parameters including userId and data to update
|
|
98
|
+
* @returns Promise with update response
|
|
99
|
+
*/
|
|
100
|
+
async updateUserData(params) {
|
|
101
|
+
try {
|
|
102
|
+
await this.ensureInitialized();
|
|
103
|
+
console.log('params', params, `${this.apiBaseUrl}/embedded-agent/user-context/update?app_user_id=${params.data.app_user_id}`);
|
|
104
|
+
console.log('updateUserData');
|
|
105
|
+
const headers = await this.getHeaders();
|
|
106
|
+
const response = await fetch(`${this.apiBaseUrl}/embedded-agent/user-context/update?app_user_id=${params.data.app_user_id}`, {
|
|
107
|
+
method: 'PUT',
|
|
108
|
+
headers,
|
|
109
|
+
body: JSON.stringify({ [params.eventKey]: params.data }),
|
|
110
|
+
});
|
|
111
|
+
const data = await response.json();
|
|
112
|
+
console.log('data after update', data);
|
|
113
|
+
if (!response.ok) {
|
|
114
|
+
throw new Error(data.error || 'Update failed');
|
|
115
|
+
}
|
|
116
|
+
return {
|
|
117
|
+
success: true,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
catch (error) {
|
|
121
|
+
console.log('updateUserData error', error);
|
|
122
|
+
return {
|
|
123
|
+
success: false,
|
|
124
|
+
error: error instanceof Error ? error.message : 'Unknown error occurred',
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Get token details for a user
|
|
130
|
+
* @param params Parameters including app_user_id and call_type
|
|
131
|
+
* @returns Promise with token details
|
|
132
|
+
*/
|
|
133
|
+
async getTokenDetails(params) {
|
|
134
|
+
try {
|
|
135
|
+
await this.ensureInitialized();
|
|
136
|
+
const headers = await this.getHeaders();
|
|
137
|
+
console.log('params', this.apiBaseUrl, params, headers, `${this.apiBaseUrl}/embedded-agent/token`);
|
|
138
|
+
const response = await fetch(`${this.apiBaseUrl}/embedded-agent/token`, {
|
|
139
|
+
method: 'POST',
|
|
140
|
+
headers,
|
|
141
|
+
body: JSON.stringify(params),
|
|
142
|
+
});
|
|
143
|
+
const data = await response.json();
|
|
144
|
+
console.log('data', data);
|
|
145
|
+
if (!response.ok) {
|
|
146
|
+
throw new Error(data.error || 'Failed to get token details');
|
|
147
|
+
}
|
|
148
|
+
return {
|
|
149
|
+
success: true,
|
|
150
|
+
data: data,
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
catch (error) {
|
|
154
|
+
console.log('getTokenDetails error', error);
|
|
155
|
+
return {
|
|
156
|
+
success: false,
|
|
157
|
+
error: error instanceof Error ? error.message : 'Unknown error occurred',
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
exports.APIService = APIService;
|
|
163
|
+
APIService.instance = null;
|
|
164
|
+
// Export convenience functions for backward compatibility
|
|
165
|
+
const initializeApi = async () => {
|
|
166
|
+
const apiService = APIService.getInstance();
|
|
167
|
+
await apiService.initialize();
|
|
168
|
+
};
|
|
169
|
+
exports.initializeApi = initializeApi;
|
|
170
|
+
const registerOnInitialize = async () => {
|
|
171
|
+
const apiService = APIService.getInstance();
|
|
172
|
+
return await apiService.registerOnInitialize();
|
|
173
|
+
};
|
|
174
|
+
exports.registerOnInitialize = registerOnInitialize;
|
|
175
|
+
const updateUserData = async (params) => {
|
|
176
|
+
const apiService = APIService.getInstance();
|
|
177
|
+
return await apiService.updateUserData(params);
|
|
178
|
+
};
|
|
179
|
+
exports.updateUserData = updateUserData;
|
|
180
|
+
const getTokenDetails = async (params) => {
|
|
181
|
+
const apiService = APIService.getInstance();
|
|
182
|
+
return await apiService.getTokenDetails(params);
|
|
183
|
+
};
|
|
184
|
+
exports.getTokenDetails = getTokenDetails;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.deleteFromDetail = exports.getAgentData = exports.setAgentData = void 0;
|
|
7
|
+
const async_storage_1 = __importDefault(require("@react-native-async-storage/async-storage"));
|
|
8
|
+
const STORAGE_KEY = '@user_data';
|
|
9
|
+
const setAgentData = async (data, key = STORAGE_KEY) => {
|
|
10
|
+
try {
|
|
11
|
+
const jsonString = JSON.stringify(data);
|
|
12
|
+
await async_storage_1.default.setItem(key, jsonString);
|
|
13
|
+
console.log('Data saved to storage successfully');
|
|
14
|
+
}
|
|
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 async_storage_1.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
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
console.error('Storage fetch error:', error);
|
|
33
|
+
throw error; // Re-throw to allow caller to handle
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
exports.getAgentData = getAgentData;
|
|
37
|
+
const deleteFromDetail = async (key) => {
|
|
38
|
+
try {
|
|
39
|
+
await async_storage_1.default.removeItem(key);
|
|
40
|
+
console.log('Storage data reset successfully');
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
console.error('Storage reset error:', error);
|
|
44
|
+
throw error; // Re-throw to allow caller to handle
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
exports.deleteFromDetail = deleteFromDetail;
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.onwidButtonStyles = exports.createOnwidButtonStyles = exports.BUTTON_HEIGHT = exports.EXPANDED_WIDTH = exports.BUTTON_WIDTH = void 0;
|
|
4
|
+
const react_native_1 = require("react-native");
|
|
5
|
+
const { width: SCREEN_WIDTH } = react_native_1.Dimensions.get('window');
|
|
6
|
+
// Calculate dynamic dimensions based on screen size
|
|
7
|
+
const calculateDimensions = () => {
|
|
8
|
+
const isSmallScreen = SCREEN_WIDTH < 375;
|
|
9
|
+
const isLargeScreen = SCREEN_WIDTH > 768;
|
|
10
|
+
return {
|
|
11
|
+
BUTTON_WIDTH: isSmallScreen ? 60 : isLargeScreen ? 60 : 60,
|
|
12
|
+
EXPANDED_WIDTH: SCREEN_WIDTH * (isSmallScreen ? 0.9 : isLargeScreen ? 0.7 : 0.8),
|
|
13
|
+
BUTTON_HEIGHT: isSmallScreen ? 60 : isLargeScreen ? 60 : 60,
|
|
14
|
+
SPACING: {
|
|
15
|
+
SMALL: isSmallScreen ? 8 : isLargeScreen ? 16 : 12,
|
|
16
|
+
MEDIUM: isSmallScreen ? 12 : isLargeScreen ? 20 : 16,
|
|
17
|
+
LARGE: isSmallScreen ? 16 : isLargeScreen ? 24 : 20,
|
|
18
|
+
},
|
|
19
|
+
BORDER_RADIUS: {
|
|
20
|
+
SMALL: isSmallScreen ? 20 : isLargeScreen ? 30 : 25,
|
|
21
|
+
MEDIUM: isSmallScreen ? 25 : isLargeScreen ? 35 : 30,
|
|
22
|
+
LARGE: isSmallScreen ? 30 : isLargeScreen ? 40 : 35,
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
const dimensions = calculateDimensions();
|
|
27
|
+
exports.BUTTON_WIDTH = dimensions.BUTTON_WIDTH;
|
|
28
|
+
exports.EXPANDED_WIDTH = dimensions.EXPANDED_WIDTH;
|
|
29
|
+
exports.BUTTON_HEIGHT = dimensions.BUTTON_HEIGHT;
|
|
30
|
+
const createOnwidButtonStyles = (customStyles) => {
|
|
31
|
+
const { buttonWidth = exports.BUTTON_WIDTH, buttonHeight = exports.BUTTON_HEIGHT, backgroundColor = 'transparent', borderRadius = dimensions.BORDER_RADIUS.MEDIUM, marginBottom = dimensions.SPACING.LARGE, spacing = dimensions.SPACING, } = customStyles || {};
|
|
32
|
+
return react_native_1.StyleSheet.create({
|
|
33
|
+
container: {
|
|
34
|
+
position: 'absolute',
|
|
35
|
+
bottom: 0,
|
|
36
|
+
right: 0,
|
|
37
|
+
height: '100%',
|
|
38
|
+
width: '100%',
|
|
39
|
+
flexDirection: 'row',
|
|
40
|
+
justifyContent: 'flex-end',
|
|
41
|
+
alignItems: 'flex-end',
|
|
42
|
+
padding: spacing.MEDIUM,
|
|
43
|
+
backgroundColor: 'transparent',
|
|
44
|
+
pointerEvents: 'box-none',
|
|
45
|
+
},
|
|
46
|
+
button: {
|
|
47
|
+
width: buttonWidth,
|
|
48
|
+
height: buttonHeight,
|
|
49
|
+
borderRadius: borderRadius,
|
|
50
|
+
marginBottom: marginBottom,
|
|
51
|
+
backgroundColor: backgroundColor,
|
|
52
|
+
},
|
|
53
|
+
pressable: {
|
|
54
|
+
borderRadius: 100,
|
|
55
|
+
padding: 5,
|
|
56
|
+
margin: 0,
|
|
57
|
+
justifyContent: 'center',
|
|
58
|
+
alignItems: 'center',
|
|
59
|
+
height: '100%',
|
|
60
|
+
width: '100%',
|
|
61
|
+
},
|
|
62
|
+
menu: {
|
|
63
|
+
position: 'absolute',
|
|
64
|
+
top: 0,
|
|
65
|
+
backgroundColor: 'white',
|
|
66
|
+
borderRadius: dimensions.BORDER_RADIUS.SMALL,
|
|
67
|
+
padding: spacing.MEDIUM,
|
|
68
|
+
},
|
|
69
|
+
menuLeft: {
|
|
70
|
+
right: '100%',
|
|
71
|
+
marginRight: spacing.SMALL,
|
|
72
|
+
},
|
|
73
|
+
menuRight: {
|
|
74
|
+
left: '100%',
|
|
75
|
+
marginLeft: spacing.SMALL,
|
|
76
|
+
},
|
|
77
|
+
iconText: {
|
|
78
|
+
color: 'white',
|
|
79
|
+
fontSize: 20,
|
|
80
|
+
},
|
|
81
|
+
buttonContent: {
|
|
82
|
+
flexDirection: 'row',
|
|
83
|
+
alignItems: 'center',
|
|
84
|
+
// height: '100%',
|
|
85
|
+
},
|
|
86
|
+
iconImage: {
|
|
87
|
+
width: buttonWidth - 10,
|
|
88
|
+
height: buttonHeight - 10,
|
|
89
|
+
resizeMode: 'contain',
|
|
90
|
+
justifyContent: 'center',
|
|
91
|
+
alignItems: 'center',
|
|
92
|
+
alignSelf: 'center',
|
|
93
|
+
margin: 0,
|
|
94
|
+
padding: 0,
|
|
95
|
+
},
|
|
96
|
+
startCallButton: {
|
|
97
|
+
height: 36,
|
|
98
|
+
borderRadius: dimensions.BORDER_RADIUS.MEDIUM,
|
|
99
|
+
backgroundColor: '#000',
|
|
100
|
+
justifyContent: 'center',
|
|
101
|
+
alignItems: 'center',
|
|
102
|
+
paddingHorizontal: spacing.SMALL + 5,
|
|
103
|
+
minWidth: 70,
|
|
104
|
+
maxWidth: '90%',
|
|
105
|
+
},
|
|
106
|
+
startCallText: {
|
|
107
|
+
color: 'white',
|
|
108
|
+
fontSize: 12,
|
|
109
|
+
fontWeight: '500',
|
|
110
|
+
},
|
|
111
|
+
rowContainer: {
|
|
112
|
+
flexDirection: 'row',
|
|
113
|
+
alignItems: 'center',
|
|
114
|
+
justifyContent: 'center',
|
|
115
|
+
height: '100%',
|
|
116
|
+
margin: 0,
|
|
117
|
+
padding: 0,
|
|
118
|
+
},
|
|
119
|
+
linearGradient: {
|
|
120
|
+
flex: 1,
|
|
121
|
+
borderRadius: dimensions.BORDER_RADIUS.LARGE,
|
|
122
|
+
flexDirection: 'row',
|
|
123
|
+
width: exports.BUTTON_WIDTH,
|
|
124
|
+
},
|
|
125
|
+
buttonContainer: {
|
|
126
|
+
flexDirection: 'row',
|
|
127
|
+
alignItems: 'center',
|
|
128
|
+
gap: 4,
|
|
129
|
+
},
|
|
130
|
+
endCallButton: {
|
|
131
|
+
justifyContent: 'center',
|
|
132
|
+
alignItems: 'center',
|
|
133
|
+
width: 44,
|
|
134
|
+
height: 44,
|
|
135
|
+
},
|
|
136
|
+
muteButton: {
|
|
137
|
+
borderRadius: 100,
|
|
138
|
+
justifyContent: 'center',
|
|
139
|
+
alignItems: 'center',
|
|
140
|
+
width: 44,
|
|
141
|
+
height: 44,
|
|
142
|
+
},
|
|
143
|
+
micIcon: {
|
|
144
|
+
width: 24,
|
|
145
|
+
height: 24,
|
|
146
|
+
tintColor: 'white',
|
|
147
|
+
},
|
|
148
|
+
endCallIcon: {
|
|
149
|
+
width: 24,
|
|
150
|
+
height: 24,
|
|
151
|
+
tintColor: 'white',
|
|
152
|
+
},
|
|
153
|
+
buttonImage: {
|
|
154
|
+
width: '100%',
|
|
155
|
+
height: '100%',
|
|
156
|
+
resizeMode: 'contain',
|
|
157
|
+
},
|
|
158
|
+
// New styles for expanded button layout
|
|
159
|
+
expandedContent: {
|
|
160
|
+
flexDirection: 'row',
|
|
161
|
+
flex: 1,
|
|
162
|
+
alignItems: 'center',
|
|
163
|
+
width: '100%',
|
|
164
|
+
justifyContent: 'space-between',
|
|
165
|
+
},
|
|
166
|
+
leftSection: {
|
|
167
|
+
alignItems: 'flex-start',
|
|
168
|
+
},
|
|
169
|
+
centerSection: {
|
|
170
|
+
alignItems: 'center',
|
|
171
|
+
height: '100%',
|
|
172
|
+
},
|
|
173
|
+
rightSection: {
|
|
174
|
+
justifyContent: 'flex-end',
|
|
175
|
+
alignItems: 'center',
|
|
176
|
+
},
|
|
177
|
+
agentInfoContainer: {
|
|
178
|
+
height: exports.BUTTON_HEIGHT,
|
|
179
|
+
flexDirection: 'row',
|
|
180
|
+
alignItems: 'center',
|
|
181
|
+
overflow: 'hidden',
|
|
182
|
+
},
|
|
183
|
+
agentTextContainer: {
|
|
184
|
+
justifyContent: 'center',
|
|
185
|
+
height: '100%',
|
|
186
|
+
flex: 1,
|
|
187
|
+
},
|
|
188
|
+
agentNameText: {
|
|
189
|
+
fontFamily: 'Inter-Medium',
|
|
190
|
+
fontSize: 14,
|
|
191
|
+
fontWeight: '500',
|
|
192
|
+
color: 'white',
|
|
193
|
+
},
|
|
194
|
+
statusText: {
|
|
195
|
+
fontFamily: 'Inter-Regular',
|
|
196
|
+
fontSize: 11,
|
|
197
|
+
fontWeight: '300',
|
|
198
|
+
color: 'white',
|
|
199
|
+
},
|
|
200
|
+
// Chip styles
|
|
201
|
+
chip: {
|
|
202
|
+
height: 30,
|
|
203
|
+
borderRadius: dimensions.BORDER_RADIUS.SMALL,
|
|
204
|
+
marginBottom: 10,
|
|
205
|
+
alignSelf: 'flex-end',
|
|
206
|
+
overflow: 'hidden',
|
|
207
|
+
elevation: 3,
|
|
208
|
+
shadowColor: '#000',
|
|
209
|
+
shadowOffset: { width: 0, height: 2 },
|
|
210
|
+
shadowOpacity: 0.3,
|
|
211
|
+
shadowRadius: 2,
|
|
212
|
+
},
|
|
213
|
+
chipGradient: {
|
|
214
|
+
height: '100%',
|
|
215
|
+
paddingHorizontal: spacing.MEDIUM,
|
|
216
|
+
paddingVertical: spacing.SMALL / 2,
|
|
217
|
+
borderRadius: dimensions.BORDER_RADIUS.SMALL,
|
|
218
|
+
justifyContent: 'center',
|
|
219
|
+
alignItems: 'center',
|
|
220
|
+
},
|
|
221
|
+
chipText: {
|
|
222
|
+
color: 'white',
|
|
223
|
+
fontSize: 12,
|
|
224
|
+
fontWeight: '500',
|
|
225
|
+
},
|
|
226
|
+
});
|
|
227
|
+
};
|
|
228
|
+
exports.createOnwidButtonStyles = createOnwidButtonStyles;
|
|
229
|
+
// Default styles export with dynamic dimensions
|
|
230
|
+
exports.onwidButtonStyles = (0, exports.createOnwidButtonStyles)();
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @file reanimatedHelpers.ts
|
|
4
|
+
* @description Utility functions to handle react-native-reanimated configuration and provide fallbacks
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.getReanimatedAPI = getReanimatedAPI;
|
|
8
|
+
exports.checkReanimatedSetup = checkReanimatedSetup;
|
|
9
|
+
exports.showReanimatedSetupError = showReanimatedSetupError;
|
|
10
|
+
let reanimatedAPI;
|
|
11
|
+
/**
|
|
12
|
+
* Safely loads react-native-reanimated and provides fallbacks if not available
|
|
13
|
+
*/
|
|
14
|
+
function getReanimatedAPI() {
|
|
15
|
+
if (reanimatedAPI) {
|
|
16
|
+
return reanimatedAPI;
|
|
17
|
+
}
|
|
18
|
+
try {
|
|
19
|
+
const reanimated = require('react-native-reanimated');
|
|
20
|
+
// Check if makeMutable is available (this is what was causing the original error)
|
|
21
|
+
if (!reanimated.makeMutable) {
|
|
22
|
+
throw new Error('makeMutable not found - react-native-reanimated may not be properly configured');
|
|
23
|
+
}
|
|
24
|
+
reanimatedAPI = {
|
|
25
|
+
useSharedValue: reanimated.useSharedValue,
|
|
26
|
+
useAnimatedStyle: reanimated.useAnimatedStyle,
|
|
27
|
+
withTiming: reanimated.withTiming,
|
|
28
|
+
withSpring: reanimated.withSpring,
|
|
29
|
+
withRepeat: reanimated.withRepeat,
|
|
30
|
+
withSequence: reanimated.withSequence,
|
|
31
|
+
runOnJS: reanimated.runOnJS,
|
|
32
|
+
Easing: reanimated.Easing,
|
|
33
|
+
Animated: reanimated.default,
|
|
34
|
+
isAvailable: true,
|
|
35
|
+
};
|
|
36
|
+
console.log('✅ react-native-reanimated loaded successfully');
|
|
37
|
+
return reanimatedAPI;
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
console.warn('⚠️ react-native-reanimated is not properly installed or configured:', error);
|
|
41
|
+
console.warn('📚 Please follow the setup guide: https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/getting-started');
|
|
42
|
+
// Provide fallback implementations
|
|
43
|
+
const { View } = require('react-native');
|
|
44
|
+
reanimatedAPI = {
|
|
45
|
+
useSharedValue: (value) => ({ value }),
|
|
46
|
+
useAnimatedStyle: () => ({}),
|
|
47
|
+
withTiming: (value) => value,
|
|
48
|
+
withSpring: (value) => value,
|
|
49
|
+
withRepeat: (value) => value,
|
|
50
|
+
withSequence: (...args) => args[args.length - 1],
|
|
51
|
+
runOnJS: (fn) => fn,
|
|
52
|
+
Easing: {
|
|
53
|
+
inOut: (easing) => easing,
|
|
54
|
+
ease: (t) => t,
|
|
55
|
+
},
|
|
56
|
+
Animated: View,
|
|
57
|
+
isAvailable: false,
|
|
58
|
+
};
|
|
59
|
+
return reanimatedAPI;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Check if react-native-reanimated is properly configured
|
|
64
|
+
*/
|
|
65
|
+
function checkReanimatedSetup() {
|
|
66
|
+
const api = getReanimatedAPI();
|
|
67
|
+
return api.isAvailable;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Display a helpful error message if reanimated is not configured
|
|
71
|
+
*/
|
|
72
|
+
function showReanimatedSetupError() {
|
|
73
|
+
console.error(`
|
|
74
|
+
🚨 React Native Reanimated Setup Required
|
|
75
|
+
|
|
76
|
+
The OnwidButton component requires react-native-reanimated to be properly installed and configured.
|
|
77
|
+
|
|
78
|
+
Quick Fix:
|
|
79
|
+
1. Install: npm install react-native-reanimated
|
|
80
|
+
2. Add to babel.config.js:
|
|
81
|
+
plugins: ['react-native-reanimated/plugin']
|
|
82
|
+
3. Rebuild your app
|
|
83
|
+
|
|
84
|
+
For detailed setup instructions, visit:
|
|
85
|
+
https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/getting-started
|
|
86
|
+
`);
|
|
87
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
type EventCallback = (data: any) => void;
|
|
2
|
+
export declare enum EventKeys {
|
|
3
|
+
USER_DATA = "user_data",
|
|
4
|
+
SCREEN_STATE = "state_data"
|
|
5
|
+
}
|
|
6
|
+
declare class OnWid {
|
|
7
|
+
private events;
|
|
8
|
+
private ensureDefaultListener;
|
|
9
|
+
Event(eventKey: string, data: any): Promise<void>;
|
|
10
|
+
on(eventKey: EventKeys, callback: EventCallback): void;
|
|
11
|
+
}
|
|
12
|
+
declare const onwid: OnWid;
|
|
13
|
+
export default onwid;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file OnwidButton.tsx
|
|
3
|
+
* @description A customizable floating action button component for React Native applications.
|
|
4
|
+
* This component provides a draggable, expandable button with animation support and gradient styling.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* OnwidButton Component
|
|
8
|
+
*
|
|
9
|
+
* A floating action button that can be dragged around the screen and expanded to show additional content.
|
|
10
|
+
* Features include:
|
|
11
|
+
* - Draggable functionality
|
|
12
|
+
* - Expandable menu
|
|
13
|
+
* - Animated transitions
|
|
14
|
+
* - Gradient background
|
|
15
|
+
* - Customizable styling
|
|
16
|
+
*
|
|
17
|
+
* @component
|
|
18
|
+
* @example
|
|
19
|
+
* ```tsx
|
|
20
|
+
* <OnwidButton
|
|
21
|
+
* isOpen={false}
|
|
22
|
+
* onPress={(isOpen) => console.log('Button pressed:', isOpen)}
|
|
23
|
+
* menuComponent={<YourMenuComponent />}
|
|
24
|
+
* />
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare function OnwidButton(): import("react/jsx-runtime").JSX.Element | null;
|
|
28
|
+
export default OnwidButton;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Room } from 'livekit-client';
|
|
2
|
+
import { RefObject } from 'react';
|
|
3
|
+
interface VoiceProps {
|
|
4
|
+
url: string;
|
|
5
|
+
token: string;
|
|
6
|
+
onDisconnected: (data: string) => void;
|
|
7
|
+
onConnected: (data: string) => void;
|
|
8
|
+
roomRef: RefObject<Room>;
|
|
9
|
+
}
|
|
10
|
+
export interface VoiceRef {
|
|
11
|
+
mute: () => void;
|
|
12
|
+
unmute: () => void;
|
|
13
|
+
}
|
|
14
|
+
declare const Voice: (props: VoiceProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
15
|
+
export default Voice;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ConnectionState, Room } from 'livekit-client';
|
|
2
|
+
import { RefObject } from 'react';
|
|
3
|
+
export type UseVoiceAgentReturn = {
|
|
4
|
+
initializeVoiceAgent: () => Promise<void>;
|
|
5
|
+
isLoading: boolean;
|
|
6
|
+
error: string | null;
|
|
7
|
+
tokenDetails: any;
|
|
8
|
+
endCall: () => Promise<void>;
|
|
9
|
+
room: Room;
|
|
10
|
+
roomRef: RefObject<Room>;
|
|
11
|
+
isMicMuted: boolean;
|
|
12
|
+
muteMic: () => void;
|
|
13
|
+
unmuteMic: () => void;
|
|
14
|
+
connectionState: ConnectionState;
|
|
15
|
+
cleanup: () => void;
|
|
16
|
+
};
|