@revrag-ai/embed-react-native 1.0.5 → 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.
Files changed (94) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +13 -382
  3. package/android/CMakeLists.txt +15 -0
  4. package/android/build.gradle +77 -25
  5. package/android/cpp-adapter.cpp +8 -0
  6. package/android/generated/java/com/revragai/embedreactnative/NativeEmbedReactNativeSpec.java +37 -0
  7. package/android/generated/jni/CMakeLists.txt +49 -0
  8. package/android/generated/jni/RNEmbedReactNativeSpec-generated.cpp +32 -0
  9. package/android/generated/jni/RNEmbedReactNativeSpec.h +31 -0
  10. package/android/generated/jni/react/renderer/components/RNEmbedReactNativeSpec/RNEmbedReactNativeSpecJSI-generated.cpp +28 -0
  11. package/android/generated/jni/react/renderer/components/RNEmbedReactNativeSpec/RNEmbedReactNativeSpecJSI.h +67 -0
  12. package/android/gradle.properties +5 -5
  13. package/cpp/revrag-ai-embed-react-native.cpp +7 -0
  14. package/cpp/revrag-ai-embed-react-native.h +8 -0
  15. package/ios/EmbedReactNative.h +9 -0
  16. package/ios/{Onwid.mm → EmbedReactNative.mm} +4 -4
  17. package/ios/generated/RNEmbedReactNativeSpec/RNEmbedReactNativeSpec-generated.mm +29 -0
  18. package/ios/generated/RNEmbedReactNativeSpec/RNEmbedReactNativeSpec.h +50 -0
  19. package/ios/generated/RNEmbedReactNativeSpecJSI-generated.cpp +28 -0
  20. package/ios/generated/RNEmbedReactNativeSpecJSI.h +67 -0
  21. package/lib/commonjs/NativeEmbedReactNative.js +9 -0
  22. package/lib/commonjs/api/api.js +256 -0
  23. package/lib/commonjs/api/types/embed.api.types.js +2 -0
  24. package/lib/commonjs/components/Embed/EmbedAudioWave.js +157 -0
  25. package/lib/commonjs/components/Embed/EmbedButton.js +511 -0
  26. package/lib/commonjs/components/Embed/EmbedVoice.js +131 -0
  27. package/lib/commonjs/components/styles/EmbedButton.style.js +248 -0
  28. package/lib/commonjs/events/embed.event.js +74 -0
  29. package/lib/commonjs/hooks/initialize.js +102 -0
  30. package/lib/commonjs/hooks/initialize.livekit.js +20 -0
  31. package/lib/commonjs/hooks/types/initialize.types.js +2 -0
  32. package/lib/commonjs/hooks/types/voiceAgent.types.js +6 -0
  33. package/lib/commonjs/hooks/voiceagent.js +358 -0
  34. package/lib/commonjs/index.js +34 -0
  35. package/lib/commonjs/index.types.js +22 -0
  36. package/lib/commonjs/store/store.key.js +46 -0
  37. package/lib/commonjs/utils/reanimated.helper.js +100 -0
  38. package/lib/module/NativeEmbedReactNative.js +5 -0
  39. package/lib/module/api/api.js +248 -0
  40. package/lib/module/api/types/embed.api.types.js +2 -0
  41. package/lib/module/components/Embed/EmbedAudioWave.js +152 -0
  42. package/lib/module/components/Embed/EmbedButton.js +506 -0
  43. package/lib/module/components/Embed/EmbedVoice.js +127 -0
  44. package/lib/module/components/styles/EmbedButton.style.js +243 -0
  45. package/lib/module/events/embed.event.js +70 -0
  46. package/lib/module/hooks/initialize.js +79 -75
  47. package/lib/module/hooks/{initializelivekit.js → initialize.livekit.js} +7 -4
  48. package/lib/module/hooks/types/initialize.types.js +2 -0
  49. package/lib/module/hooks/types/voiceAgent.types.js +4 -0
  50. package/lib/module/hooks/voiceagent.js +353 -0
  51. package/lib/module/index.js +6 -60
  52. package/lib/module/index.types.js +23 -0
  53. package/lib/module/store/store.key.js +38 -0
  54. package/lib/module/utils/reanimated.helper.js +94 -0
  55. package/lib/typescript/commonjs/package.json +1 -0
  56. package/lib/typescript/module/package.json +1 -0
  57. package/package.json +69 -27
  58. package/react-native.config.js +8 -14
  59. package/revrag-ai-embed-react-native.podspec +41 -0
  60. package/Onwid.podspec +0 -20
  61. package/ios/Onwid.h +0 -5
  62. package/lib/index.d.ts +0 -77
  63. package/lib/module/Event/onwid.js +0 -74
  64. package/lib/module/NativeOnwid.js +0 -4
  65. package/lib/module/component/OnwidButton.js +0 -366
  66. package/lib/module/component/audiowave.js +0 -137
  67. package/lib/module/component/voice.js +0 -103
  68. package/lib/module/hooks/initialize.types.js +0 -2
  69. package/lib/module/hooks/voiceAgent.js +0 -334
  70. package/lib/module/hooks/voiceAgent.types.js +0 -2
  71. package/lib/module/onwidApi/api.js +0 -184
  72. package/lib/module/onwidApi/api.types.js +0 -2
  73. package/lib/module/store.key.js +0 -47
  74. package/lib/module/style/onwidButton.style.js +0 -230
  75. package/lib/module/utils/reanimatedHelpers.js +0 -87
  76. package/lib/module/utils/utils.js +0 -1
  77. package/lib/typescript/Event/onwid.d.ts +0 -13
  78. package/lib/typescript/NativeOnwid.d.ts +0 -6
  79. package/lib/typescript/component/OnwidButton.d.ts +0 -28
  80. package/lib/typescript/component/audiowave.d.ts +0 -6
  81. package/lib/typescript/component/voice.d.ts +0 -15
  82. package/lib/typescript/hooks/initialize.d.ts +0 -2
  83. package/lib/typescript/hooks/initialize.types.d.ts +0 -5
  84. package/lib/typescript/hooks/initializelivekit.d.ts +0 -3
  85. package/lib/typescript/hooks/voiceAgent.d.ts +0 -2
  86. package/lib/typescript/hooks/voiceAgent.types.d.ts +0 -16
  87. package/lib/typescript/index.d.ts +0 -27
  88. package/lib/typescript/onwidApi/api.d.ts +0 -53
  89. package/lib/typescript/onwidApi/api.types.d.ts +0 -21
  90. package/lib/typescript/store.key.d.ts +0 -3
  91. package/lib/typescript/style/onwidButton.style.d.ts +0 -98
  92. package/lib/typescript/utils/reanimatedHelpers.d.ts +0 -29
  93. package/lib/typescript/utils/utils.d.ts +0 -0
  94. package/scripts/verify-setup.js +0 -90
package/package.json CHANGED
@@ -1,19 +1,23 @@
1
1
  {
2
2
  "name": "@revrag-ai/embed-react-native",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
+ "source": "./src/index.tsx",
4
5
  "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",
6
+ "main": "./lib/commonjs/index.js",
7
+ "module": "./lib/module/index.js",
8
+ "types": "./lib/typescript/commonjs/src/index.d.ts",
7
9
  "typesVersions": {
8
10
  "*": {
9
- "*": ["./lib/typescript/src/*", "./lib/index.d.ts"]
11
+ "*": [
12
+ "./lib/typescript/commonjs/src/*"
13
+ ]
10
14
  }
11
15
  },
12
16
  "exports": {
13
17
  ".": {
14
- "types": "./lib/typescript/src/index.d.ts",
18
+ "types": "./lib/typescript/commonjs/src/index.d.ts",
15
19
  "import": "./lib/module/index.js",
16
- "require": "./lib/module/index.js",
20
+ "require": "./lib/commonjs/index.js",
17
21
  "default": "./lib/module/index.js"
18
22
  },
19
23
  "./package.json": "./package.json"
@@ -48,16 +52,17 @@
48
52
  "typecheck": "tsc",
49
53
  "lint": "eslint \"**/*.{js,ts,tsx}\"",
50
54
  "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",
55
+ "prepare": "bob build",
56
+ "build": "bob build",
53
57
  "fix-js": "node fix-js-files.js",
54
58
  "verify-setup": "node scripts/verify-setup.js",
55
- "prepublishOnly": "yarn manual-build && yarn fix-js",
59
+ "debug-network": "node scripts/debug-network.js",
60
+ "prepublishOnly": "bob build && yarn fix-js",
56
61
  "release": "release-it --only-version",
57
62
  "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"
63
+ "publish:safe": "yarn clean && bob build && yarn fix-js && yarn protect && npm publish --access public",
64
+ "publish:beta": "yarn clean && bob build && yarn fix-js && yarn protect && npm publish --access public --tag beta",
65
+ "publish:alpha": "yarn clean && bob build && yarn fix-js && yarn protect && npm publish --access public --tag alpha"
61
66
  },
62
67
  "keywords": [
63
68
  "react-native",
@@ -74,17 +79,16 @@
74
79
  ],
75
80
  "repository": {
76
81
  "type": "git",
77
- "url": "git+https://github.com/RevRag-ai/embed-react-native.git"
82
+ "url": "git+https://github.com/orgs/RevRag-ai/dashboard.git"
78
83
  },
79
- "author": "RevRag AI <contact@revrag.ai> (https://www.revrag.ai)",
84
+ "author": "RevragAi <contact@revrag.ai> (https://www.revrag.ai)",
80
85
  "license": "MIT",
81
86
  "bugs": {
82
- "url": "https://github.com/RevRag-ai/embed-react-native/issues"
87
+ "url": "https://github.com/orgs/RevRag-ai/dashboard/issues"
83
88
  },
84
- "homepage": "https://github.com/RevRag-ai/embed-react-native#readme",
89
+ "homepage": "https://github.com/orgs/RevRag-ai/dashboard#readme",
85
90
  "publishConfig": {
86
- "registry": "https://registry.npmjs.org/",
87
- "access": "public"
91
+ "registry": "https://registry.npmjs.org/"
88
92
  },
89
93
  "devDependencies": {
90
94
  "@babel/core": "^7.20.0",
@@ -117,6 +121,9 @@
117
121
  "release-it": "^15.0.0",
118
122
  "typescript": "^5.2.2"
119
123
  },
124
+ "resolutions": {
125
+ "@types/react": "^18.2.44"
126
+ },
120
127
  "peerDependencies": {
121
128
  "@livekit/react-native": "*",
122
129
  "@livekit/react-native-webrtc": "*",
@@ -158,12 +165,34 @@
158
165
  },
159
166
  "plugins": {
160
167
  "@release-it/conventional-changelog": {
161
- "preset": {
162
- "name": "angular"
163
- }
168
+ "preset": "angular"
164
169
  }
165
170
  }
166
171
  },
172
+ "eslintConfig": {
173
+ "root": true,
174
+ "extends": [
175
+ "@react-native",
176
+ "prettier"
177
+ ],
178
+ "rules": {
179
+ "react/react-in-jsx-scope": "off",
180
+ "prettier/prettier": [
181
+ "error",
182
+ {
183
+ "quoteProps": "consistent",
184
+ "singleQuote": true,
185
+ "tabWidth": 2,
186
+ "trailingComma": "es5",
187
+ "useTabs": false
188
+ }
189
+ ]
190
+ }
191
+ },
192
+ "eslintIgnore": [
193
+ "node_modules/",
194
+ "lib/"
195
+ ],
167
196
  "prettier": {
168
197
  "quoteProps": "consistent",
169
198
  "singleQuote": true,
@@ -175,6 +204,13 @@
175
204
  "source": "src",
176
205
  "output": "lib",
177
206
  "targets": [
207
+ "codegen",
208
+ [
209
+ "commonjs",
210
+ {
211
+ "esm": true
212
+ }
213
+ ],
178
214
  [
179
215
  "module",
180
216
  {
@@ -184,23 +220,29 @@
184
220
  [
185
221
  "typescript",
186
222
  {
187
- "project": "tsconfig.build.json"
223
+ "project": "tsconfig.build.json",
224
+ "esm": true
188
225
  }
189
226
  ]
190
227
  ]
191
228
  },
192
229
  "codegenConfig": {
193
- "name": "OnwidSpec",
230
+ "name": "RNEmbedReactNativeSpec",
194
231
  "type": "modules",
195
232
  "jsSrcsDir": "src",
233
+ "outputDir": {
234
+ "ios": "ios/generated",
235
+ "android": "android/generated"
236
+ },
196
237
  "android": {
197
- "javaPackageName": "com.onwid"
198
- }
238
+ "javaPackageName": "com.revragai.embedreactnative"
239
+ },
240
+ "includesGeneratedCode": true
199
241
  },
200
242
  "create-react-native-library": {
201
- "languages": "kotlin-objc",
202
243
  "type": "turbo-module",
203
- "version": "0.50.3"
244
+ "languages": "cpp",
245
+ "version": "0.46.0"
204
246
  },
205
247
  "dependencies": {
206
248
  "livekit-client": "^2.13.1"
@@ -1,18 +1,12 @@
1
+ /* eslint-disable */
2
+ /**
3
+ * @type {import('@react-native-community/cli-types').UserDependencyConfig}
4
+ */
1
5
  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
- },
6
+ dependency: {
7
+ platforms: {
8
+ android: {
9
+ cmakeListsPath: 'generated/jni/CMakeLists.txt',
16
10
  },
17
11
  },
18
12
  },
@@ -0,0 +1,41 @@
1
+ require "json"
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
+ folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
5
+
6
+ Pod::Spec.new do |s|
7
+ s.name = "revrag-ai-embed-react-native"
8
+ s.version = package["version"]
9
+ s.summary = package["description"]
10
+ s.homepage = package["homepage"]
11
+ s.license = package["license"]
12
+ s.authors = package["author"]
13
+
14
+ s.platforms = { :ios => min_ios_version_supported }
15
+ s.source = { :git => "https://github.com/orgs/RevRag-ai/dashboard.git", :tag => "#{s.version}" }
16
+
17
+ s.source_files = "ios/**/*.{h,m,mm}", "cpp/**/*.{hpp,cpp,c,h}"
18
+
19
+ # Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
20
+ # See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
21
+ if respond_to?(:install_modules_dependencies, true)
22
+ install_modules_dependencies(s)
23
+ else
24
+ s.dependency "React-Core"
25
+
26
+ # Don't install the dependencies when we run `pod install` in the old architecture.
27
+ if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
28
+ s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
29
+ s.pod_target_xcconfig = {
30
+ "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
31
+ "OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
32
+ "CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
33
+ }
34
+ s.dependency "React-Codegen"
35
+ s.dependency "RCT-Folly"
36
+ s.dependency "RCTRequired"
37
+ s.dependency "RCTTypeSafety"
38
+ s.dependency "ReactCommon/turbomodule/core"
39
+ end
40
+ end
41
+ end
package/Onwid.podspec DELETED
@@ -1,20 +0,0 @@
1
- require "json"
2
-
3
- package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
-
5
- Pod::Spec.new do |s|
6
- s.name = "Onwid"
7
- s.version = package["version"]
8
- s.summary = package["description"]
9
- s.homepage = package["homepage"]
10
- s.license = package["license"]
11
- s.authors = package["author"]
12
-
13
- s.platforms = { :ios => min_ios_version_supported }
14
- s.source = { :git => "https://github.com/RevRag-ai.git", :tag => "#{s.version}" }
15
-
16
- s.source_files = "ios/**/*.{h,m,mm,cpp}"
17
- s.private_header_files = "ios/**/*.h"
18
-
19
- install_modules_dependencies(s)
20
- end
package/ios/Onwid.h DELETED
@@ -1,5 +0,0 @@
1
- #import <OnwidSpec/OnwidSpec.h>
2
-
3
- @interface Onwid : NSObject <NativeOnwidSpec>
4
-
5
- @end
package/lib/index.d.ts DELETED
@@ -1,77 +0,0 @@
1
- /**
2
- * @file index.d.ts
3
- * @description TypeScript declarations for the Onwid React Native library.
4
- */
5
-
6
- import { ConnectionState, Room } from 'livekit-client';
7
- import { RefObject } from 'react';
8
-
9
- // Component declarations
10
- export declare function OnwidButton(): JSX.Element;
11
-
12
- // Hook type declarations
13
- export interface UseInitializeProps {
14
- apiKey: string;
15
- agentId?: string;
16
- onwidUrl?: string;
17
- metadata?: any;
18
- }
19
-
20
- export interface UseVoiceAgentReturn {
21
- initializeVoiceAgent: () => Promise<void>;
22
- isLoading: boolean;
23
- error: string | null;
24
- tokenDetails: any;
25
- endCall: () => Promise<void>;
26
- room: Room;
27
- roomRef: RefObject<Room>;
28
- isMicMuted: boolean;
29
- muteMic: () => void;
30
- unmuteMic: () => void;
31
- connectionState: ConnectionState;
32
- cleanup: () => void;
33
- }
34
-
35
- // Hook declarations
36
- export declare const useInitialize: (props: UseInitializeProps) => void;
37
- export declare const useVoiceAgent: () => UseVoiceAgentReturn;
38
-
39
- // API type declarations
40
- export interface ApiResponse<T> {
41
- success: boolean;
42
- data?: T;
43
- error?: string;
44
- }
45
-
46
- export interface RegisterRequest {
47
- apiKey: string;
48
- onwidUrl: string;
49
- metadata?: Record<string, any>;
50
- }
51
-
52
- export interface TokenDetails {
53
- token: string;
54
- expiresAt: number;
55
- apiKey: string;
56
- config: Record<string, any>;
57
- server_url: string;
58
- }
59
-
60
- export interface UpdateDataRequest {
61
- eventKey: string;
62
- data: Record<string, any>;
63
- }
64
-
65
- // Event system declarations
66
- export enum EventKeys {
67
- USER_DATA = 'user_data',
68
- SCREEN_STATE = 'state_data',
69
- }
70
-
71
- export declare class OnWid {
72
- Event(eventKey: string, data: any): Promise<void>;
73
- on(eventKey: EventKeys, callback: (data: any) => void): void;
74
- }
75
-
76
- export declare const onwid: OnWid;
77
- export declare const registerAgent: any;
@@ -1,74 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EventKeys = void 0;
4
- const store_key_1 = require("../store.key");
5
- const api_1 = require("../onwidApi/api");
6
- // Predefined event keys
7
- var EventKeys;
8
- (function (EventKeys) {
9
- EventKeys["USER_DATA"] = "user_data";
10
- EventKeys["SCREEN_STATE"] = "state_data";
11
- })(EventKeys || (exports.EventKeys = EventKeys = {}));
12
- class OnWid {
13
- constructor() {
14
- this.events = {};
15
- }
16
- // Automatically adds a default listener if none exists
17
- ensureDefaultListener(eventKey) {
18
- if (!this.events[eventKey]) {
19
- this.events[eventKey] = [
20
- (data) => {
21
- console.log(`[Default] Event handled for ${eventKey}:`, data);
22
- },
23
- ];
24
- }
25
- }
26
- async Event(eventKey, data) {
27
- var _a;
28
- if (!Object.values(EventKeys).includes(eventKey)) {
29
- console.error(`Invalid event key: ${eventKey}`);
30
- throw new Error(`Invalid event key: ${eventKey}. Must be one of: ${Object.values(EventKeys).join(', ')}`);
31
- }
32
- const key = eventKey;
33
- if (key !== EventKeys.USER_DATA) {
34
- const userIdentity = await (0, store_key_1.getAgentData)(EventKeys.USER_DATA);
35
- if (userIdentity) {
36
- data.app_user_id = userIdentity.app_user_id;
37
- }
38
- else {
39
- throw new Error('User identity not found');
40
- }
41
- }
42
- // Ensure a default listener is registered if not already
43
- this.ensureDefaultListener(key);
44
- console.log('response,updateUserDatniuioioioa');
45
- // Trigger API call
46
- try {
47
- const apiService = api_1.APIService.getInstance();
48
- const response = await apiService.updateUserData({
49
- eventKey: key,
50
- data,
51
- });
52
- console.log('response,updateUserData', response);
53
- if (!response.success) {
54
- console.error('Failed to trigger API for event:', eventKey);
55
- }
56
- (0, store_key_1.setAgentData)(data, key);
57
- }
58
- catch (error) {
59
- console.error('Error triggering API:', error);
60
- }
61
- // Trigger event listeners
62
- (_a = this.events[key]) === null || _a === void 0 ? void 0 : _a.forEach((callback) => callback(data));
63
- }
64
- // Still allow custom listeners (optional)
65
- on(eventKey, callback) {
66
- var _a;
67
- if (!this.events[eventKey]) {
68
- this.events[eventKey] = [];
69
- }
70
- (_a = this.events[eventKey]) === null || _a === void 0 ? void 0 : _a.push(callback);
71
- }
72
- }
73
- const onwid = new OnWid();
74
- exports.default = onwid;
@@ -1,4 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const react_native_1 = require("react-native");
4
- exports.default = react_native_1.TurboModuleRegistry.getEnforcing('Onwid');