@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
@@ -0,0 +1,32 @@
1
+
2
+ /**
3
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
4
+ *
5
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
6
+ * once the code is regenerated.
7
+ *
8
+ * @generated by codegen project: GenerateModuleJniCpp.js
9
+ */
10
+
11
+ #include "RNEmbedReactNativeSpec.h"
12
+
13
+ namespace facebook::react {
14
+
15
+ static facebook::jsi::Value __hostFunction_NativeEmbedReactNativeSpecJSI_multiply(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
16
+ static jmethodID cachedMethodId = nullptr;
17
+ return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, NumberKind, "multiply", "(DD)D", args, count, cachedMethodId);
18
+ }
19
+
20
+ NativeEmbedReactNativeSpecJSI::NativeEmbedReactNativeSpecJSI(const JavaTurboModule::InitParams &params)
21
+ : JavaTurboModule(params) {
22
+ methodMap_["multiply"] = MethodMetadata {2, __hostFunction_NativeEmbedReactNativeSpecJSI_multiply};
23
+ }
24
+
25
+ std::shared_ptr<TurboModule> RNEmbedReactNativeSpec_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams &params) {
26
+ if (moduleName == "EmbedReactNative") {
27
+ return std::make_shared<NativeEmbedReactNativeSpecJSI>(params);
28
+ }
29
+ return nullptr;
30
+ }
31
+
32
+ } // namespace facebook::react
@@ -0,0 +1,31 @@
1
+
2
+ /**
3
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
4
+ *
5
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
6
+ * once the code is regenerated.
7
+ *
8
+ * @generated by codegen project: GenerateModuleJniH.js
9
+ */
10
+
11
+ #pragma once
12
+
13
+ #include <ReactCommon/JavaTurboModule.h>
14
+ #include <ReactCommon/TurboModule.h>
15
+ #include <jsi/jsi.h>
16
+
17
+ namespace facebook::react {
18
+
19
+ /**
20
+ * JNI C++ class for module 'NativeEmbedReactNative'
21
+ */
22
+ class JSI_EXPORT NativeEmbedReactNativeSpecJSI : public JavaTurboModule {
23
+ public:
24
+ NativeEmbedReactNativeSpecJSI(const JavaTurboModule::InitParams &params);
25
+ };
26
+
27
+
28
+ JSI_EXPORT
29
+ std::shared_ptr<TurboModule> RNEmbedReactNativeSpec_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams &params);
30
+
31
+ } // namespace facebook::react
@@ -0,0 +1,28 @@
1
+ /**
2
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
3
+ *
4
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
5
+ * once the code is regenerated.
6
+ *
7
+ * @generated by codegen project: GenerateModuleCpp.js
8
+ */
9
+
10
+ #include "RNEmbedReactNativeSpecJSI.h"
11
+
12
+ namespace facebook::react {
13
+
14
+ static jsi::Value __hostFunction_NativeEmbedReactNativeCxxSpecJSI_multiply(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
15
+ return static_cast<NativeEmbedReactNativeCxxSpecJSI *>(&turboModule)->multiply(
16
+ rt,
17
+ count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asNumber(),
18
+ count <= 1 ? throw jsi::JSError(rt, "Expected argument in position 1 to be passed") : args[1].asNumber()
19
+ );
20
+ }
21
+
22
+ NativeEmbedReactNativeCxxSpecJSI::NativeEmbedReactNativeCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker)
23
+ : TurboModule("EmbedReactNative", jsInvoker) {
24
+ methodMap_["multiply"] = MethodMetadata {2, __hostFunction_NativeEmbedReactNativeCxxSpecJSI_multiply};
25
+ }
26
+
27
+
28
+ } // namespace facebook::react
@@ -0,0 +1,67 @@
1
+ /**
2
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
3
+ *
4
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
5
+ * once the code is regenerated.
6
+ *
7
+ * @generated by codegen project: GenerateModuleH.js
8
+ */
9
+
10
+ #pragma once
11
+
12
+ #include <ReactCommon/TurboModule.h>
13
+ #include <react/bridging/Bridging.h>
14
+
15
+ namespace facebook::react {
16
+
17
+
18
+ class JSI_EXPORT NativeEmbedReactNativeCxxSpecJSI : public TurboModule {
19
+ protected:
20
+ NativeEmbedReactNativeCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker);
21
+
22
+ public:
23
+ virtual double multiply(jsi::Runtime &rt, double a, double b) = 0;
24
+
25
+ };
26
+
27
+ template <typename T>
28
+ class JSI_EXPORT NativeEmbedReactNativeCxxSpec : public TurboModule {
29
+ public:
30
+ jsi::Value get(jsi::Runtime &rt, const jsi::PropNameID &propName) override {
31
+ return delegate_.get(rt, propName);
32
+ }
33
+
34
+ static constexpr std::string_view kModuleName = "EmbedReactNative";
35
+
36
+ protected:
37
+ NativeEmbedReactNativeCxxSpec(std::shared_ptr<CallInvoker> jsInvoker)
38
+ : TurboModule(std::string{NativeEmbedReactNativeCxxSpec::kModuleName}, jsInvoker),
39
+ delegate_(reinterpret_cast<T*>(this), jsInvoker) {}
40
+
41
+
42
+ private:
43
+ class Delegate : public NativeEmbedReactNativeCxxSpecJSI {
44
+ public:
45
+ Delegate(T *instance, std::shared_ptr<CallInvoker> jsInvoker) :
46
+ NativeEmbedReactNativeCxxSpecJSI(std::move(jsInvoker)), instance_(instance) {
47
+
48
+ }
49
+
50
+ double multiply(jsi::Runtime &rt, double a, double b) override {
51
+ static_assert(
52
+ bridging::getParameterCount(&T::multiply) == 3,
53
+ "Expected multiply(...) to have 3 parameters");
54
+
55
+ return bridging::callFromJs<double>(
56
+ rt, &T::multiply, jsInvoker_, instance_, std::move(a), std::move(b));
57
+ }
58
+
59
+ private:
60
+ friend class NativeEmbedReactNativeCxxSpec;
61
+ T *instance_;
62
+ };
63
+
64
+ Delegate delegate_;
65
+ };
66
+
67
+ } // namespace facebook::react
@@ -1,5 +1,5 @@
1
- Onwid_kotlinVersion=2.0.21
2
- Onwid_minSdkVersion=24
3
- Onwid_targetSdkVersion=34
4
- Onwid_compileSdkVersion=35
5
- Onwid_ndkVersion=27.1.12297006
1
+ EmbedReactNative_kotlinVersion=1.7.0
2
+ EmbedReactNative_minSdkVersion=21
3
+ EmbedReactNative_targetSdkVersion=31
4
+ EmbedReactNative_compileSdkVersion=31
5
+ EmbedReactNative_ndkversion=21.4.7075529
@@ -0,0 +1,7 @@
1
+ #include "revrag-ai-embed-react-native.h"
2
+
3
+ namespace revragai_embedreactnative {
4
+ double multiply(double a, double b) {
5
+ return a * b;
6
+ }
7
+ }
@@ -0,0 +1,8 @@
1
+ #ifndef REVRAGAI_EMBEDREACTNATIVE_H
2
+ #define REVRAGAI_EMBEDREACTNATIVE_H
3
+
4
+ namespace revragai_embedreactnative {
5
+ double multiply(double a, double b);
6
+ }
7
+
8
+ #endif /* REVRAGAI_EMBEDREACTNATIVE_H */
@@ -0,0 +1,9 @@
1
+ #ifdef __cplusplus
2
+ #import "revrag-ai-embed-react-native.h"
3
+ #endif
4
+
5
+ #import "generated/RNEmbedReactNativeSpec/RNEmbedReactNativeSpec.h"
6
+
7
+ @interface EmbedReactNative : NSObject <NativeEmbedReactNativeSpec>
8
+
9
+ @end
@@ -1,10 +1,10 @@
1
- #import "Onwid.h"
1
+ #import "EmbedReactNative.h"
2
2
 
3
- @implementation Onwid
3
+ @implementation EmbedReactNative
4
4
  RCT_EXPORT_MODULE()
5
5
 
6
6
  - (NSNumber *)multiply:(double)a b:(double)b {
7
- NSNumber *result = @(a * b);
7
+ NSNumber *result = @(revragai_embedreactnative::multiply(a, b));
8
8
 
9
9
  return result;
10
10
  }
@@ -12,7 +12,7 @@ RCT_EXPORT_MODULE()
12
12
  - (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
13
13
  (const facebook::react::ObjCTurboModule::InitParams &)params
14
14
  {
15
- return std::make_shared<facebook::react::NativeOnwidSpecJSI>(params);
15
+ return std::make_shared<facebook::react::NativeEmbedReactNativeSpecJSI>(params);
16
16
  }
17
17
 
18
18
  @end
@@ -0,0 +1,29 @@
1
+ /**
2
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
3
+ *
4
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
5
+ * once the code is regenerated.
6
+ *
7
+ * @generated by codegen project: GenerateModuleObjCpp
8
+ *
9
+ * We create an umbrella header (and corresponding implementation) here since
10
+ * Cxx compilation in BUCK has a limitation: source-code producing genrule()s
11
+ * must have a single output. More files => more genrule()s => slower builds.
12
+ */
13
+
14
+ #import "RNEmbedReactNativeSpec.h"
15
+
16
+
17
+ namespace facebook::react {
18
+
19
+ static facebook::jsi::Value __hostFunction_NativeEmbedReactNativeSpecJSI_multiply(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
20
+ return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, NumberKind, "multiply", @selector(multiply:b:), args, count);
21
+ }
22
+
23
+ NativeEmbedReactNativeSpecJSI::NativeEmbedReactNativeSpecJSI(const ObjCTurboModule::InitParams &params)
24
+ : ObjCTurboModule(params) {
25
+
26
+ methodMap_["multiply"] = MethodMetadata {2, __hostFunction_NativeEmbedReactNativeSpecJSI_multiply};
27
+
28
+ }
29
+ } // namespace facebook::react
@@ -0,0 +1,50 @@
1
+ /**
2
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
3
+ *
4
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
5
+ * once the code is regenerated.
6
+ *
7
+ * @generated by codegen project: GenerateModuleObjCpp
8
+ *
9
+ * We create an umbrella header (and corresponding implementation) here since
10
+ * Cxx compilation in BUCK has a limitation: source-code producing genrule()s
11
+ * must have a single output. More files => more genrule()s => slower builds.
12
+ */
13
+
14
+ #ifndef __cplusplus
15
+ #error This file must be compiled as Obj-C++. If you are importing it, you must change your file extension to .mm.
16
+ #endif
17
+
18
+ // Avoid multiple includes of RNEmbedReactNativeSpec symbols
19
+ #ifndef RNEmbedReactNativeSpec_H
20
+ #define RNEmbedReactNativeSpec_H
21
+
22
+ #import <Foundation/Foundation.h>
23
+ #import <RCTRequired/RCTRequired.h>
24
+ #import <RCTTypeSafety/RCTConvertHelpers.h>
25
+ #import <RCTTypeSafety/RCTTypedModuleConstants.h>
26
+ #import <React/RCTBridgeModule.h>
27
+ #import <React/RCTCxxConvert.h>
28
+ #import <React/RCTManagedPointer.h>
29
+ #import <ReactCommon/RCTTurboModule.h>
30
+ #import <optional>
31
+ #import <vector>
32
+
33
+
34
+ @protocol NativeEmbedReactNativeSpec <RCTBridgeModule, RCTTurboModule>
35
+
36
+ - (NSNumber *)multiply:(double)a
37
+ b:(double)b;
38
+
39
+ @end
40
+ namespace facebook::react {
41
+ /**
42
+ * ObjC++ class for module 'NativeEmbedReactNative'
43
+ */
44
+ class JSI_EXPORT NativeEmbedReactNativeSpecJSI : public ObjCTurboModule {
45
+ public:
46
+ NativeEmbedReactNativeSpecJSI(const ObjCTurboModule::InitParams &params);
47
+ };
48
+ } // namespace facebook::react
49
+
50
+ #endif // RNEmbedReactNativeSpec_H
@@ -0,0 +1,28 @@
1
+ /**
2
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
3
+ *
4
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
5
+ * once the code is regenerated.
6
+ *
7
+ * @generated by codegen project: GenerateModuleCpp.js
8
+ */
9
+
10
+ #include "RNEmbedReactNativeSpecJSI.h"
11
+
12
+ namespace facebook::react {
13
+
14
+ static jsi::Value __hostFunction_NativeEmbedReactNativeCxxSpecJSI_multiply(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
15
+ return static_cast<NativeEmbedReactNativeCxxSpecJSI *>(&turboModule)->multiply(
16
+ rt,
17
+ count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asNumber(),
18
+ count <= 1 ? throw jsi::JSError(rt, "Expected argument in position 1 to be passed") : args[1].asNumber()
19
+ );
20
+ }
21
+
22
+ NativeEmbedReactNativeCxxSpecJSI::NativeEmbedReactNativeCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker)
23
+ : TurboModule("EmbedReactNative", jsInvoker) {
24
+ methodMap_["multiply"] = MethodMetadata {2, __hostFunction_NativeEmbedReactNativeCxxSpecJSI_multiply};
25
+ }
26
+
27
+
28
+ } // namespace facebook::react
@@ -0,0 +1,67 @@
1
+ /**
2
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
3
+ *
4
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
5
+ * once the code is regenerated.
6
+ *
7
+ * @generated by codegen project: GenerateModuleH.js
8
+ */
9
+
10
+ #pragma once
11
+
12
+ #include <ReactCommon/TurboModule.h>
13
+ #include <react/bridging/Bridging.h>
14
+
15
+ namespace facebook::react {
16
+
17
+
18
+ class JSI_EXPORT NativeEmbedReactNativeCxxSpecJSI : public TurboModule {
19
+ protected:
20
+ NativeEmbedReactNativeCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker);
21
+
22
+ public:
23
+ virtual double multiply(jsi::Runtime &rt, double a, double b) = 0;
24
+
25
+ };
26
+
27
+ template <typename T>
28
+ class JSI_EXPORT NativeEmbedReactNativeCxxSpec : public TurboModule {
29
+ public:
30
+ jsi::Value get(jsi::Runtime &rt, const jsi::PropNameID &propName) override {
31
+ return delegate_.get(rt, propName);
32
+ }
33
+
34
+ static constexpr std::string_view kModuleName = "EmbedReactNative";
35
+
36
+ protected:
37
+ NativeEmbedReactNativeCxxSpec(std::shared_ptr<CallInvoker> jsInvoker)
38
+ : TurboModule(std::string{NativeEmbedReactNativeCxxSpec::kModuleName}, jsInvoker),
39
+ delegate_(reinterpret_cast<T*>(this), jsInvoker) {}
40
+
41
+
42
+ private:
43
+ class Delegate : public NativeEmbedReactNativeCxxSpecJSI {
44
+ public:
45
+ Delegate(T *instance, std::shared_ptr<CallInvoker> jsInvoker) :
46
+ NativeEmbedReactNativeCxxSpecJSI(std::move(jsInvoker)), instance_(instance) {
47
+
48
+ }
49
+
50
+ double multiply(jsi::Runtime &rt, double a, double b) override {
51
+ static_assert(
52
+ bridging::getParameterCount(&T::multiply) == 3,
53
+ "Expected multiply(...) to have 3 parameters");
54
+
55
+ return bridging::callFromJs<double>(
56
+ rt, &T::multiply, jsInvoker_, instance_, std::move(a), std::move(b));
57
+ }
58
+
59
+ private:
60
+ friend class NativeEmbedReactNativeCxxSpec;
61
+ T *instance_;
62
+ };
63
+
64
+ Delegate delegate_;
65
+ };
66
+
67
+ } // namespace facebook::react
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _reactNative = require("react-native");
8
+ var _default = exports.default = _reactNative.TurboModuleRegistry.getEnforcing('EmbedReactNative');
9
+ //# sourceMappingURL=NativeEmbedReactNative.js.map
@@ -0,0 +1,256 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.updateUserData = exports.registerOnInitialize = exports.initializeApi = exports.getTokenDetails = exports.APIService = void 0;
7
+ var _storeKey = require("../store/store.key.js");
8
+ /**
9
+ * APIService class that ensures proper initialization before API calls
10
+ */
11
+ class APIService {
12
+ static instance = null;
13
+ apiBaseUrl = null;
14
+ isInitialized = false;
15
+ constructor() {}
16
+
17
+ /**
18
+ * Get singleton instance of APIService
19
+ */
20
+ static getInstance() {
21
+ if (!APIService.instance) {
22
+ APIService.instance = new APIService();
23
+ }
24
+ return APIService.instance;
25
+ }
26
+
27
+ /**
28
+ * Initialize the API service with the base URL
29
+ */
30
+ async initialize() {
31
+ if (this.isInitialized && this.apiBaseUrl) {
32
+ return; // Already initialized
33
+ }
34
+ const AgentData = await (0, _storeKey.getAgentData)();
35
+ console.log('AgentData', AgentData);
36
+ if (AgentData?.onwidUrl) {
37
+ this.apiBaseUrl = AgentData.onwidUrl;
38
+ this.isInitialized = true;
39
+ console.log('API_BASE_URL initialized:', this.apiBaseUrl);
40
+ } else {
41
+ throw new Error('API base URL not found in keychain');
42
+ }
43
+ }
44
+
45
+ /**
46
+ * Ensure the service is initialized before making API calls
47
+ */
48
+ async ensureInitialized() {
49
+ if (!this.isInitialized || !this.apiBaseUrl) {
50
+ await this.initialize();
51
+ }
52
+ }
53
+
54
+ /**
55
+ * Get headers with stored API key
56
+ */
57
+ async getHeaders() {
58
+ const AgentData = await (0, _storeKey.getAgentData)();
59
+ if (!AgentData?.apiKey) {
60
+ throw new Error('API key not found in keychain');
61
+ }
62
+ return {
63
+ 'Content-Type': 'application/json',
64
+ 'Authorization': `Bearer ${AgentData.apiKey}`,
65
+ 'X-Revrag-Embedded-Key': AgentData.apiKey
66
+ };
67
+ }
68
+
69
+ /**
70
+ * Register a new user/device on initialization
71
+ * @returns Promise with registration response
72
+ */
73
+ async registerOnInitialize() {
74
+ try {
75
+ await this.ensureInitialized();
76
+ console.log('registerOnInitialize ApiData', this.apiBaseUrl);
77
+ const headers = await this.getHeaders();
78
+ const response = await fetch(`${this.apiBaseUrl}/embedded-agent/initialize`, {
79
+ method: 'GET',
80
+ headers: headers
81
+ });
82
+ const data = await response.json();
83
+ console.log('dat config data after register', data);
84
+ await (0, _storeKey.setAgentData)(data, '@config_data');
85
+ if (!response.ok) {
86
+ console.log('registerOnInitialize error', data.error);
87
+ throw new Error(data.error || 'Registration failed');
88
+ }
89
+ return {
90
+ success: true,
91
+ data: data
92
+ };
93
+ } catch (error) {
94
+ console.log('registerOnInitialize error', error);
95
+
96
+ // Enhanced error handling for common iOS network issues
97
+ let errorMessage = 'Unknown error occurred';
98
+ if (error instanceof Error) {
99
+ errorMessage = error.message;
100
+
101
+ // iOS ATS related errors
102
+ if (error.message.includes('The resource could not be loaded') || error.message.includes('App Transport Security')) {
103
+ errorMessage = `Network request blocked by iOS App Transport Security. ` + `Please configure ATS exceptions in Info.plist for HTTP endpoints, ` + `or use HTTPS instead. Error: ${error.message}`;
104
+ }
105
+
106
+ // Network connectivity errors
107
+ if (error.message.includes('Network request failed') || error.message.includes('Failed to fetch')) {
108
+ errorMessage = `Network request failed. Please check your internet connection ` + `and ensure the API endpoint (${this.apiBaseUrl}) is accessible. ` + `Error: ${error.message}`;
109
+ }
110
+
111
+ // Timeout errors
112
+ if (error.message.includes('timeout')) {
113
+ errorMessage = `Request timeout. The API server may be slow to respond or unreachable. ` + `Error: ${error.message}`;
114
+ }
115
+ }
116
+ return {
117
+ success: false,
118
+ error: errorMessage
119
+ };
120
+ }
121
+ }
122
+
123
+ /**
124
+ * Update user data
125
+ * @param params Update parameters including userId and data to update
126
+ * @returns Promise with update response
127
+ */
128
+ async updateUserData(params) {
129
+ try {
130
+ await this.ensureInitialized();
131
+ console.log('params', params, `${this.apiBaseUrl}/embedded-agent/user-context/update?app_user_id=${params.data.app_user_id}`);
132
+ console.log('updateUserData');
133
+ const headers = await this.getHeaders();
134
+ const response = await fetch(`${this.apiBaseUrl}/embedded-agent/user-context/update?app_user_id=${params.data.app_user_id}`, {
135
+ method: 'PUT',
136
+ headers,
137
+ body: JSON.stringify({
138
+ [params.eventKey]: params.data
139
+ })
140
+ });
141
+ const data = await response.json();
142
+ console.log('data after update', data);
143
+ if (!response.ok) {
144
+ throw new Error(data.error || 'Update failed');
145
+ }
146
+ return {
147
+ success: true
148
+ };
149
+ } catch (error) {
150
+ console.log('updateUserData error', error);
151
+
152
+ // Enhanced error handling for common iOS network issues
153
+ let errorMessage = 'Unknown error occurred';
154
+ if (error instanceof Error) {
155
+ errorMessage = error.message;
156
+
157
+ // iOS ATS related errors
158
+ if (error.message.includes('The resource could not be loaded') || error.message.includes('App Transport Security')) {
159
+ errorMessage = `Network request blocked by iOS App Transport Security. ` + `Please configure ATS exceptions in Info.plist for HTTP endpoints, ` + `or use HTTPS instead. Error: ${error.message}`;
160
+ }
161
+
162
+ // Network connectivity errors
163
+ if (error.message.includes('Network request failed') || error.message.includes('Failed to fetch')) {
164
+ errorMessage = `Network request failed. Please check your internet connection ` + `and ensure the API endpoint (${this.apiBaseUrl}) is accessible. ` + `Error: ${error.message}`;
165
+ }
166
+
167
+ // Timeout errors
168
+ if (error.message.includes('timeout')) {
169
+ errorMessage = `Request timeout. The API server may be slow to respond or unreachable. ` + `Error: ${error.message}`;
170
+ }
171
+ }
172
+ return {
173
+ success: false,
174
+ error: errorMessage
175
+ };
176
+ }
177
+ }
178
+
179
+ /**
180
+ * Get token details for a user
181
+ * @param params Parameters including app_user_id and call_type
182
+ * @returns Promise with token details
183
+ */
184
+ async getTokenDetails(params) {
185
+ try {
186
+ await this.ensureInitialized();
187
+ const headers = await this.getHeaders();
188
+ console.log('params', this.apiBaseUrl, params, headers, `${this.apiBaseUrl}/embedded-agent/token`);
189
+ const response = await fetch(`${this.apiBaseUrl}/embedded-agent/token`, {
190
+ method: 'POST',
191
+ headers,
192
+ body: JSON.stringify(params)
193
+ });
194
+ const data = await response.json();
195
+ console.log('data', data);
196
+ if (!response.ok) {
197
+ throw new Error(data.error || 'Failed to get token details');
198
+ }
199
+ return {
200
+ success: true,
201
+ data: data
202
+ };
203
+ } catch (error) {
204
+ console.log('getTokenDetails error', error);
205
+
206
+ // Enhanced error handling for common iOS network issues
207
+ let errorMessage = 'Unknown error occurred';
208
+ if (error instanceof Error) {
209
+ errorMessage = error.message;
210
+
211
+ // iOS ATS related errors
212
+ if (error.message.includes('The resource could not be loaded') || error.message.includes('App Transport Security')) {
213
+ errorMessage = `Network request blocked by iOS App Transport Security. ` + `Please configure ATS exceptions in Info.plist for HTTP endpoints, ` + `or use HTTPS instead. Error: ${error.message}`;
214
+ }
215
+
216
+ // Network connectivity errors
217
+ if (error.message.includes('Network request failed') || error.message.includes('Failed to fetch')) {
218
+ errorMessage = `Network request failed. Please check your internet connection ` + `and ensure the API endpoint (${this.apiBaseUrl}) is accessible. ` + `Error: ${error.message}`;
219
+ }
220
+
221
+ // Timeout errors
222
+ if (error.message.includes('timeout')) {
223
+ errorMessage = `Request timeout. The API server may be slow to respond or unreachable. ` + `Error: ${error.message}`;
224
+ }
225
+ }
226
+ return {
227
+ success: false,
228
+ error: errorMessage
229
+ };
230
+ }
231
+ }
232
+ }
233
+
234
+ // Export convenience functions for backward compatibility
235
+ exports.APIService = APIService;
236
+ const initializeApi = async () => {
237
+ const apiService = APIService.getInstance();
238
+ await apiService.initialize();
239
+ };
240
+ exports.initializeApi = initializeApi;
241
+ const registerOnInitialize = async () => {
242
+ const apiService = APIService.getInstance();
243
+ return await apiService.registerOnInitialize();
244
+ };
245
+ exports.registerOnInitialize = registerOnInitialize;
246
+ const updateUserData = async params => {
247
+ const apiService = APIService.getInstance();
248
+ return await apiService.updateUserData(params);
249
+ };
250
+ exports.updateUserData = updateUserData;
251
+ const getTokenDetails = async params => {
252
+ const apiService = APIService.getInstance();
253
+ return await apiService.getTokenDetails(params);
254
+ };
255
+ exports.getTokenDetails = getTokenDetails;
256
+ //# sourceMappingURL=api.js.map
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=embed.api.types.js.map