@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.
Files changed (45) hide show
  1. package/LICENSE +20 -0
  2. package/Onwid.podspec +20 -0
  3. package/README.md +402 -0
  4. package/android/build.gradle +83 -0
  5. package/android/gradle.properties +5 -0
  6. package/ios/Onwid.h +5 -0
  7. package/ios/Onwid.mm +18 -0
  8. package/lib/index.d.ts +77 -0
  9. package/lib/module/Event/onwid.js +74 -0
  10. package/lib/module/NativeOnwid.js +4 -0
  11. package/lib/module/component/OnwidButton.js +366 -0
  12. package/lib/module/component/audiowave.js +137 -0
  13. package/lib/module/component/voice.js +103 -0
  14. package/lib/module/hooks/initialize.js +92 -0
  15. package/lib/module/hooks/initialize.types.js +2 -0
  16. package/lib/module/hooks/initializelivekit.js +14 -0
  17. package/lib/module/hooks/voiceAgent.js +334 -0
  18. package/lib/module/hooks/voiceAgent.types.js +2 -0
  19. package/lib/module/index.js +61 -0
  20. package/lib/module/onwidApi/api.js +184 -0
  21. package/lib/module/onwidApi/api.types.js +2 -0
  22. package/lib/module/store.key.js +47 -0
  23. package/lib/module/style/onwidButton.style.js +230 -0
  24. package/lib/module/utils/reanimatedHelpers.js +87 -0
  25. package/lib/module/utils/utils.js +1 -0
  26. package/lib/typescript/Event/onwid.d.ts +13 -0
  27. package/lib/typescript/NativeOnwid.d.ts +6 -0
  28. package/lib/typescript/component/OnwidButton.d.ts +28 -0
  29. package/lib/typescript/component/audiowave.d.ts +6 -0
  30. package/lib/typescript/component/voice.d.ts +15 -0
  31. package/lib/typescript/hooks/initialize.d.ts +2 -0
  32. package/lib/typescript/hooks/initialize.types.d.ts +5 -0
  33. package/lib/typescript/hooks/initializelivekit.d.ts +3 -0
  34. package/lib/typescript/hooks/voiceAgent.d.ts +2 -0
  35. package/lib/typescript/hooks/voiceAgent.types.d.ts +16 -0
  36. package/lib/typescript/index.d.ts +27 -0
  37. package/lib/typescript/onwidApi/api.d.ts +53 -0
  38. package/lib/typescript/onwidApi/api.types.d.ts +21 -0
  39. package/lib/typescript/store.key.d.ts +3 -0
  40. package/lib/typescript/style/onwidButton.style.d.ts +98 -0
  41. package/lib/typescript/utils/reanimatedHelpers.d.ts +29 -0
  42. package/lib/typescript/utils/utils.d.ts +0 -0
  43. package/package.json +208 -0
  44. package/react-native.config.js +19 -0
  45. package/scripts/verify-setup.js +90 -0
@@ -0,0 +1,27 @@
1
+ /**
2
+ * @file index.tsx
3
+ * @description Main entry point for the Onwid React Native library.
4
+ * This file exports the core components and utilities for the Onwid SDK.
5
+ */
6
+ import onwid, { EventKeys } from './Event/onwid';
7
+ import { useInitialize } from './hooks/initialize';
8
+ import type { UseInitializeProps } from './hooks/initialize.types';
9
+ import registerAgent from './hooks/initializelivekit';
10
+ import type { ApiResponse, RegisterRequest, TokenDetails } from './onwidApi/api.types';
11
+ /**
12
+ * OnwidButton component that provides a customizable button with menu functionality
13
+ * @returns React component
14
+ */
15
+ export declare function OnwidButton(): import("react/jsx-runtime").JSX.Element;
16
+ /**
17
+ * Core exports from the Onwid library
18
+ * @exports
19
+ * @property {OnwidButton} OnwidButton - Custom button component with menu functionality
20
+ * @property {Function} registerAgent - Function to register the Agent (Optional)
21
+ * @property {OnWid} onwid - Event management system instance
22
+ * @property {useInitialize} useInitialize - Hook to initialize the Onwid SDK
23
+ * @property {useVoiceAgent} useVoiceAgent - Hook for voice agent functionality
24
+ * @property {EventKeys} EventKeys - Available event types
25
+ */
26
+ export { EventKeys, onwid, registerAgent, useInitialize };
27
+ export type { ApiResponse, RegisterRequest, TokenDetails, UseInitializeProps };
@@ -0,0 +1,53 @@
1
+ import type { ApiResponse, TokenDetails, UpdateDataRequest } from './api.types';
2
+ /**
3
+ * APIService class that ensures proper initialization before API calls
4
+ */
5
+ export declare class APIService {
6
+ private static instance;
7
+ private apiBaseUrl;
8
+ private isInitialized;
9
+ private constructor();
10
+ /**
11
+ * Get singleton instance of APIService
12
+ */
13
+ static getInstance(): APIService;
14
+ /**
15
+ * Initialize the API service with the base URL
16
+ */
17
+ initialize(): Promise<void>;
18
+ /**
19
+ * Ensure the service is initialized before making API calls
20
+ */
21
+ private ensureInitialized;
22
+ /**
23
+ * Get headers with stored API key
24
+ */
25
+ private getHeaders;
26
+ /**
27
+ * Register a new user/device on initialization
28
+ * @returns Promise with registration response
29
+ */
30
+ registerOnInitialize(): Promise<ApiResponse<TokenDetails>>;
31
+ /**
32
+ * Update user data
33
+ * @param params Update parameters including userId and data to update
34
+ * @returns Promise with update response
35
+ */
36
+ updateUserData(params: UpdateDataRequest): Promise<ApiResponse<void>>;
37
+ /**
38
+ * Get token details for a user
39
+ * @param params Parameters including app_user_id and call_type
40
+ * @returns Promise with token details
41
+ */
42
+ getTokenDetails(params: {
43
+ app_user_id: string;
44
+ call_type: string;
45
+ }): Promise<ApiResponse<TokenDetails>>;
46
+ }
47
+ export declare const initializeApi: () => Promise<void>;
48
+ export declare const registerOnInitialize: () => Promise<ApiResponse<TokenDetails>>;
49
+ export declare const updateUserData: (params: UpdateDataRequest) => Promise<ApiResponse<void>>;
50
+ export declare const getTokenDetails: (params: {
51
+ app_user_id: string;
52
+ call_type: string;
53
+ }) => Promise<ApiResponse<TokenDetails>>;
@@ -0,0 +1,21 @@
1
+ export type RegisterRequest = {
2
+ apiKey: string;
3
+ onwidUrl: string;
4
+ metadata?: Record<string, any>;
5
+ };
6
+ export type UpdateDataRequest = {
7
+ eventKey: string;
8
+ data: Record<string, any>;
9
+ };
10
+ export type TokenDetails = {
11
+ token: string;
12
+ expiresAt: number;
13
+ apiKey: string;
14
+ config: Record<string, any>;
15
+ server_url: string;
16
+ };
17
+ export type ApiResponse<T> = {
18
+ success: boolean;
19
+ data?: T;
20
+ error?: string;
21
+ };
@@ -0,0 +1,3 @@
1
+ export declare const setAgentData: (data: Record<string, any>, key?: string) => Promise<void>;
2
+ export declare const getAgentData: (key?: string) => Promise<any>;
3
+ export declare const deleteFromDetail: (key: string) => Promise<void>;
@@ -0,0 +1,98 @@
1
+ import { ViewStyle, TextStyle, ImageStyle } from 'react-native';
2
+ export declare const BUTTON_WIDTH: number;
3
+ export declare const EXPANDED_WIDTH: number;
4
+ export declare const BUTTON_HEIGHT: number;
5
+ type SpacingType = {
6
+ SMALL: number;
7
+ MEDIUM: number;
8
+ LARGE: number;
9
+ };
10
+ type CustomStyles = {
11
+ buttonWidth?: number;
12
+ buttonHeight?: number;
13
+ backgroundColor?: string;
14
+ borderRadius?: number;
15
+ marginBottom?: number;
16
+ spacing?: SpacingType;
17
+ };
18
+ export declare const createOnwidButtonStyles: (customStyles?: CustomStyles) => {
19
+ container: ViewStyle;
20
+ button: ViewStyle;
21
+ pressable: ViewStyle;
22
+ menu: ViewStyle;
23
+ menuLeft: ViewStyle;
24
+ menuRight: ViewStyle;
25
+ iconText: TextStyle;
26
+ buttonContent: ViewStyle;
27
+ iconImage: ImageStyle;
28
+ startCallButton: ViewStyle;
29
+ startCallText: TextStyle;
30
+ rowContainer: ViewStyle;
31
+ linearGradient: ViewStyle;
32
+ buttonContainer: ViewStyle;
33
+ endCallButton: ViewStyle;
34
+ muteButton: ViewStyle;
35
+ micIcon: {
36
+ width: number;
37
+ height: number;
38
+ tintColor: string;
39
+ };
40
+ endCallIcon: {
41
+ width: number;
42
+ height: number;
43
+ tintColor: string;
44
+ };
45
+ buttonImage: ImageStyle;
46
+ expandedContent: ViewStyle;
47
+ leftSection: ViewStyle;
48
+ centerSection: ViewStyle;
49
+ rightSection: ViewStyle;
50
+ agentInfoContainer: ViewStyle;
51
+ agentTextContainer: ViewStyle;
52
+ agentNameText: TextStyle;
53
+ statusText: TextStyle;
54
+ chip: ViewStyle;
55
+ chipGradient: ViewStyle;
56
+ chipText: TextStyle;
57
+ };
58
+ export declare const onwidButtonStyles: {
59
+ container: ViewStyle;
60
+ button: ViewStyle;
61
+ pressable: ViewStyle;
62
+ menu: ViewStyle;
63
+ menuLeft: ViewStyle;
64
+ menuRight: ViewStyle;
65
+ iconText: TextStyle;
66
+ buttonContent: ViewStyle;
67
+ iconImage: ImageStyle;
68
+ startCallButton: ViewStyle;
69
+ startCallText: TextStyle;
70
+ rowContainer: ViewStyle;
71
+ linearGradient: ViewStyle;
72
+ buttonContainer: ViewStyle;
73
+ endCallButton: ViewStyle;
74
+ muteButton: ViewStyle;
75
+ micIcon: {
76
+ width: number;
77
+ height: number;
78
+ tintColor: string;
79
+ };
80
+ endCallIcon: {
81
+ width: number;
82
+ height: number;
83
+ tintColor: string;
84
+ };
85
+ buttonImage: ImageStyle;
86
+ expandedContent: ViewStyle;
87
+ leftSection: ViewStyle;
88
+ centerSection: ViewStyle;
89
+ rightSection: ViewStyle;
90
+ agentInfoContainer: ViewStyle;
91
+ agentTextContainer: ViewStyle;
92
+ agentNameText: TextStyle;
93
+ statusText: TextStyle;
94
+ chip: ViewStyle;
95
+ chipGradient: ViewStyle;
96
+ chipText: TextStyle;
97
+ };
98
+ export {};
@@ -0,0 +1,29 @@
1
+ /**
2
+ * @file reanimatedHelpers.ts
3
+ * @description Utility functions to handle react-native-reanimated configuration and provide fallbacks
4
+ */
5
+ interface ReanimatedAPI {
6
+ useSharedValue: any;
7
+ useAnimatedStyle: any;
8
+ withTiming: any;
9
+ withSpring: any;
10
+ withRepeat: any;
11
+ withSequence: any;
12
+ runOnJS: any;
13
+ Easing: any;
14
+ Animated: any;
15
+ isAvailable: boolean;
16
+ }
17
+ /**
18
+ * Safely loads react-native-reanimated and provides fallbacks if not available
19
+ */
20
+ export declare function getReanimatedAPI(): ReanimatedAPI;
21
+ /**
22
+ * Check if react-native-reanimated is properly configured
23
+ */
24
+ export declare function checkReanimatedSetup(): boolean;
25
+ /**
26
+ * Display a helpful error message if reanimated is not configured
27
+ */
28
+ export declare function showReanimatedSetupError(): void;
29
+ export {};
File without changes
package/package.json ADDED
@@ -0,0 +1,208 @@
1
+ {
2
+ "name": "@revrag-ai/embed-react-native",
3
+ "version": "1.0.5",
4
+ "description": "Voice Agent SDK for React Native - AI-powered voice communication with real-time speech processing",
5
+ "main": "./lib/module/index.js",
6
+ "types": "./lib/typescript/src/index.d.ts",
7
+ "typesVersions": {
8
+ "*": {
9
+ "*": ["./lib/typescript/src/*", "./lib/index.d.ts"]
10
+ }
11
+ },
12
+ "exports": {
13
+ ".": {
14
+ "types": "./lib/typescript/src/index.d.ts",
15
+ "import": "./lib/module/index.js",
16
+ "require": "./lib/module/index.js",
17
+ "default": "./lib/module/index.js"
18
+ },
19
+ "./package.json": "./package.json"
20
+ },
21
+ "files": [
22
+ "lib",
23
+ "android",
24
+ "ios",
25
+ "cpp",
26
+ "assets",
27
+ "scripts",
28
+ "*.podspec",
29
+ "react-native.config.js",
30
+ "!lib/**/*.map",
31
+ "!lib/**/*.test.*",
32
+ "!lib/**/*.spec.*",
33
+ "!ios/build",
34
+ "!android/build",
35
+ "!android/gradle",
36
+ "!android/gradlew",
37
+ "!android/gradlew.bat",
38
+ "!android/local.properties",
39
+ "!**/__tests__",
40
+ "!**/__fixtures__",
41
+ "!**/__mocks__",
42
+ "!**/.*",
43
+ "!src"
44
+ ],
45
+ "scripts": {
46
+ "example": "yarn workspace embed-react-native-example",
47
+ "test": "jest",
48
+ "typecheck": "tsc",
49
+ "lint": "eslint \"**/*.{js,ts,tsx}\"",
50
+ "clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
51
+ "prepare": "yarn manual-build",
52
+ "manual-build": "node manual-build.js",
53
+ "fix-js": "node fix-js-files.js",
54
+ "verify-setup": "node scripts/verify-setup.js",
55
+ "prepublishOnly": "yarn manual-build && yarn fix-js",
56
+ "release": "release-it --only-version",
57
+ "protect": "node -e \"const crypto = require('crypto'); const fs = require('fs'); const config = { hash: crypto.randomBytes(32).toString('hex'), createdAt: new Date().toISOString(), note: 'Protected build', version: require('./package.json').version }; fs.writeFileSync('.onwid-security.json', JSON.stringify(config, null, 2)); console.log('āœ… Code protected');\"",
58
+ "publish:safe": "yarn clean && yarn manual-build && yarn fix-js && yarn protect && npm publish --access public",
59
+ "publish:beta": "yarn clean && yarn manual-build && yarn fix-js && yarn protect && npm publish --access public --tag beta",
60
+ "publish:alpha": "yarn clean && yarn manual-build && yarn fix-js && yarn protect && npm publish --access public --tag alpha"
61
+ },
62
+ "keywords": [
63
+ "react-native",
64
+ "ios",
65
+ "android",
66
+ "voice-agent",
67
+ "ai-voice",
68
+ "speech",
69
+ "voice-sdk",
70
+ "real-time-communication",
71
+ "voice-chat",
72
+ "ai-assistant",
73
+ "conversational-ai"
74
+ ],
75
+ "repository": {
76
+ "type": "git",
77
+ "url": "git+https://github.com/RevRag-ai/embed-react-native.git"
78
+ },
79
+ "author": "RevRag AI <contact@revrag.ai> (https://www.revrag.ai)",
80
+ "license": "MIT",
81
+ "bugs": {
82
+ "url": "https://github.com/RevRag-ai/embed-react-native/issues"
83
+ },
84
+ "homepage": "https://github.com/RevRag-ai/embed-react-native#readme",
85
+ "publishConfig": {
86
+ "registry": "https://registry.npmjs.org/",
87
+ "access": "public"
88
+ },
89
+ "devDependencies": {
90
+ "@babel/core": "^7.20.0",
91
+ "@babel/preset-env": "^7.20.0",
92
+ "@babel/runtime": "^7.20.0",
93
+ "@livekit/react-native": "^2.7.4",
94
+ "@livekit/react-native-webrtc": "^125.0.9",
95
+ "@react-native-async-storage/async-storage": "^2.1.2",
96
+ "@react-native/babel-preset": "0.75.4",
97
+ "@react-native/eslint-config": "0.75.4",
98
+ "@react-native/metro-config": "0.75.4",
99
+ "@react-native/typescript-config": "0.75.4",
100
+ "@release-it/conventional-changelog": "^5.0.0",
101
+ "@types/jest": "^29.5.5",
102
+ "@types/react": "^18.2.44",
103
+ "del-cli": "^5.1.0",
104
+ "eslint": "^8.51.0",
105
+ "eslint-config-prettier": "^9.0.0",
106
+ "eslint-plugin-prettier": "^5.0.1",
107
+ "jest": "^29.7.0",
108
+ "lottie-react-native": "^7.2.2",
109
+ "prettier": "^3.0.3",
110
+ "react": "18.3.1",
111
+ "react-native": "0.75.4",
112
+ "react-native-builder-bob": "^0.30.2",
113
+ "react-native-gesture-handler": "^2.25.0",
114
+ "react-native-linear-gradient": "^2.8.3",
115
+ "react-native-reanimated": "^3.17.5",
116
+ "react-native-safe-area-context": "^4.12.0",
117
+ "release-it": "^15.0.0",
118
+ "typescript": "^5.2.2"
119
+ },
120
+ "peerDependencies": {
121
+ "@livekit/react-native": "*",
122
+ "@livekit/react-native-webrtc": "*",
123
+ "@react-native-async-storage/async-storage": "*",
124
+ "lottie-react-native": "*",
125
+ "react": "*",
126
+ "react-native": "*",
127
+ "react-native-gesture-handler": "*",
128
+ "react-native-linear-gradient": "*",
129
+ "react-native-reanimated": "*",
130
+ "react-native-safe-area-context": "*"
131
+ },
132
+ "workspaces": [
133
+ "example"
134
+ ],
135
+ "packageManager": "yarn@3.6.1",
136
+ "jest": {
137
+ "preset": "react-native",
138
+ "modulePathIgnorePatterns": [
139
+ "<rootDir>/example/node_modules",
140
+ "<rootDir>/lib/"
141
+ ]
142
+ },
143
+ "commitlint": {
144
+ "extends": [
145
+ "@commitlint/config-conventional"
146
+ ]
147
+ },
148
+ "release-it": {
149
+ "git": {
150
+ "commitMessage": "chore: release ${version}",
151
+ "tagName": "v${version}"
152
+ },
153
+ "npm": {
154
+ "publish": true
155
+ },
156
+ "github": {
157
+ "release": true
158
+ },
159
+ "plugins": {
160
+ "@release-it/conventional-changelog": {
161
+ "preset": {
162
+ "name": "angular"
163
+ }
164
+ }
165
+ }
166
+ },
167
+ "prettier": {
168
+ "quoteProps": "consistent",
169
+ "singleQuote": true,
170
+ "tabWidth": 2,
171
+ "trailingComma": "es5",
172
+ "useTabs": false
173
+ },
174
+ "react-native-builder-bob": {
175
+ "source": "src",
176
+ "output": "lib",
177
+ "targets": [
178
+ [
179
+ "module",
180
+ {
181
+ "esm": true
182
+ }
183
+ ],
184
+ [
185
+ "typescript",
186
+ {
187
+ "project": "tsconfig.build.json"
188
+ }
189
+ ]
190
+ ]
191
+ },
192
+ "codegenConfig": {
193
+ "name": "OnwidSpec",
194
+ "type": "modules",
195
+ "jsSrcsDir": "src",
196
+ "android": {
197
+ "javaPackageName": "com.onwid"
198
+ }
199
+ },
200
+ "create-react-native-library": {
201
+ "languages": "kotlin-objc",
202
+ "type": "turbo-module",
203
+ "version": "0.50.3"
204
+ },
205
+ "dependencies": {
206
+ "livekit-client": "^2.13.1"
207
+ }
208
+ }
@@ -0,0 +1,19 @@
1
+ module.exports = {
2
+ assets: ['./assets/'],
3
+ dependencies: {
4
+ '@revrag-ai/embed-react-native': {
5
+ platforms: {
6
+ android: {
7
+ sourceDir: './android',
8
+ packageImportPath: 'import com.onwid.OnwidPackage;',
9
+ packageInstance: 'new OnwidPackage()',
10
+ assets: ['./assets/'],
11
+ },
12
+ ios: {
13
+ podspecPath: './Onwid.podspec',
14
+ assets: ['./assets/'],
15
+ },
16
+ },
17
+ },
18
+ },
19
+ };
@@ -0,0 +1,90 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Onwid Setup Verification Script
5
+ * Run this script to verify that all dependencies are properly installed and configured.
6
+ */
7
+
8
+ const fs = require('fs');
9
+ const path = require('path');
10
+
11
+ console.log('šŸ” Verifying Onwid setup...\n');
12
+
13
+ let hasErrors = false;
14
+
15
+ // Check if react-native-reanimated is installed
16
+ try {
17
+ const packageJson = require(path.join(process.cwd(), 'package.json'));
18
+ const dependencies = { ...packageJson.dependencies, ...packageJson.devDependencies };
19
+
20
+ if (dependencies['react-native-reanimated']) {
21
+ console.log('āœ… react-native-reanimated is installed:', dependencies['react-native-reanimated']);
22
+ } else {
23
+ console.log('āŒ react-native-reanimated is not installed');
24
+ console.log(' Fix: npm install react-native-reanimated');
25
+ hasErrors = true;
26
+ }
27
+ } catch (error) {
28
+ console.log('āŒ Cannot read package.json');
29
+ hasErrors = true;
30
+ }
31
+
32
+ // Check babel.config.js
33
+ const babelConfigPath = path.join(process.cwd(), 'babel.config.js');
34
+ if (fs.existsSync(babelConfigPath)) {
35
+ try {
36
+ const babelConfig = fs.readFileSync(babelConfigPath, 'utf8');
37
+ if (babelConfig.includes('react-native-reanimated/plugin')) {
38
+ console.log('āœ… babel.config.js includes react-native-reanimated plugin');
39
+ } else {
40
+ console.log('āŒ babel.config.js missing react-native-reanimated plugin');
41
+ console.log(' Fix: Add "react-native-reanimated/plugin" to your plugins array');
42
+ hasErrors = true;
43
+ }
44
+ } catch (error) {
45
+ console.log('āŒ Cannot read babel.config.js');
46
+ hasErrors = true;
47
+ }
48
+ } else {
49
+ console.log('āŒ babel.config.js not found');
50
+ hasErrors = true;
51
+ }
52
+
53
+ // Check other required dependencies
54
+ const requiredDeps = [
55
+ '@livekit/react-native',
56
+ '@livekit/react-native-webrtc',
57
+ '@react-native-async-storage/async-storage',
58
+ 'lottie-react-native',
59
+ 'react-native-gesture-handler',
60
+ 'react-native-linear-gradient',
61
+ 'react-native-safe-area-context'
62
+ ];
63
+
64
+ console.log('\nšŸ“¦ Checking other required dependencies:');
65
+ try {
66
+ const packageJson = require(path.join(process.cwd(), 'package.json'));
67
+ const allDeps = { ...packageJson.dependencies, ...packageJson.devDependencies, ...packageJson.peerDependencies };
68
+
69
+ requiredDeps.forEach(dep => {
70
+ if (allDeps[dep]) {
71
+ console.log(`āœ… ${dep}: ${allDeps[dep]}`);
72
+ } else {
73
+ console.log(`āš ļø ${dep}: Not found (should be installed as peer dependency)`);
74
+ }
75
+ });
76
+ } catch (error) {
77
+ console.log('āŒ Cannot check dependencies');
78
+ }
79
+
80
+ // Final result
81
+ console.log('\n' + '='.repeat(50));
82
+ if (hasErrors) {
83
+ console.log('āŒ Setup has issues. Please fix the errors above.');
84
+ console.log('\nšŸ“š For detailed setup instructions, visit:');
85
+ console.log(' https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/getting-started');
86
+ process.exit(1);
87
+ } else {
88
+ console.log('āœ… Setup verification passed!');
89
+ console.log('šŸš€ You should be able to use @revrag-ai/embed-react-native without issues.');
90
+ }