livevoice-sdk-react-native 2.0.0 → 3.0.0

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 (221) hide show
  1. package/README.md +158 -7
  2. package/android/build.gradle +18 -6
  3. package/android/src/main/java/io/livevoice/react/LiveVoiceModule.kt +121 -221
  4. package/android/src/main/java/io/livevoice/react/__SDK.kt +17 -3
  5. package/ios/LiveVoiceRNBridge.swift +362 -0
  6. package/ios/LiveVoiceSdkReactNative.mm +247 -145
  7. package/ios/__SDK.h +16 -2
  8. package/ios/livevoice_spm_backport.rb +202 -0
  9. package/lib/module/components/BrandingView.js +71 -50
  10. package/lib/module/components/BrandingView.js.map +1 -1
  11. package/lib/module/components/ChannelView.js +368 -54
  12. package/lib/module/components/ChannelView.js.map +1 -1
  13. package/lib/module/components/ErrorView.js +17 -16
  14. package/lib/module/components/ErrorView.js.map +1 -1
  15. package/lib/module/components/LiveVoiceSpinner.js +81 -0
  16. package/lib/module/components/LiveVoiceSpinner.js.map +1 -0
  17. package/lib/module/components/LiveVoiceView.js +351 -104
  18. package/lib/module/components/LiveVoiceView.js.map +1 -1
  19. package/lib/module/components/PasswordPrompt.js +165 -0
  20. package/lib/module/components/PasswordPrompt.js.map +1 -0
  21. package/lib/module/components/PlayButtonView.js +192 -254
  22. package/lib/module/components/PlayButtonView.js.map +1 -1
  23. package/lib/module/components/ReconnectingView.js +43 -62
  24. package/lib/module/components/ReconnectingView.js.map +1 -1
  25. package/lib/module/components/WarningView.js +12 -10
  26. package/lib/module/components/WarningView.js.map +1 -1
  27. package/lib/module/icons/branding-ios.png +0 -0
  28. package/lib/module/icons/camera-off-android.png +0 -0
  29. package/lib/module/icons/camera-off-android@2x.png +0 -0
  30. package/lib/module/icons/camera-off-android@3x.png +0 -0
  31. package/lib/module/icons/cpu-android.png +0 -0
  32. package/lib/module/icons/cpu-android@2x.png +0 -0
  33. package/lib/module/icons/cpu-android@3x.png +0 -0
  34. package/lib/module/icons/cpu-ios.png +0 -0
  35. package/lib/module/icons/cpu-ios@2x.png +0 -0
  36. package/lib/module/icons/cpu-ios@3x.png +0 -0
  37. package/lib/module/icons/lock-android.png +0 -0
  38. package/lib/module/icons/lock-android@2x.png +0 -0
  39. package/lib/module/icons/lock-android@3x.png +0 -0
  40. package/lib/module/icons/lock-ios.png +0 -0
  41. package/lib/module/icons/lock-ios@2x.png +0 -0
  42. package/lib/module/icons/lock-ios@3x.png +0 -0
  43. package/lib/module/icons/mic-off-android.png +0 -0
  44. package/lib/module/icons/mic-off-android@2x.png +0 -0
  45. package/lib/module/icons/mic-off-android@3x.png +0 -0
  46. package/lib/module/icons/mic-slash-ios.png +0 -0
  47. package/lib/module/icons/mic-slash-ios@2x.png +0 -0
  48. package/lib/module/icons/mic-slash-ios@3x.png +0 -0
  49. package/lib/module/icons/video-slash-ios.png +0 -0
  50. package/lib/module/icons/video-slash-ios@2x.png +0 -0
  51. package/lib/module/icons/video-slash-ios@3x.png +0 -0
  52. package/lib/module/index.js +24 -225
  53. package/lib/module/index.js.map +1 -1
  54. package/lib/module/sdk/Bridge.js +236 -0
  55. package/lib/module/sdk/Bridge.js.map +1 -0
  56. package/lib/module/sdk/Event.js +160 -0
  57. package/lib/module/sdk/Event.js.map +1 -0
  58. package/lib/module/sdk/Lifecycle.js +331 -0
  59. package/lib/module/sdk/Lifecycle.js.map +1 -0
  60. package/lib/module/sdk/LiveVoiceSdk.js +365 -0
  61. package/lib/module/sdk/LiveVoiceSdk.js.map +1 -0
  62. package/lib/module/sdk/LiveVoiceState.js +234 -0
  63. package/lib/module/sdk/LiveVoiceState.js.map +1 -0
  64. package/lib/module/sdk/LogEntries.js +99 -0
  65. package/lib/module/sdk/LogEntries.js.map +1 -0
  66. package/lib/module/sdk/Models.js +2 -0
  67. package/lib/module/{util/UIState.js.map → sdk/Models.js.map} +1 -1
  68. package/lib/module/sdk/NativeSdkVersions.js +24 -0
  69. package/lib/module/sdk/NativeSdkVersions.js.map +1 -0
  70. package/lib/module/sdk/Observables.js +391 -0
  71. package/lib/module/sdk/Observables.js.map +1 -0
  72. package/lib/module/sdk/Passwords.js +298 -0
  73. package/lib/module/sdk/Passwords.js.map +1 -0
  74. package/lib/module/sdk/Playback.js +35 -0
  75. package/lib/module/sdk/Playback.js.map +1 -0
  76. package/lib/module/specs/NativeLiveVoiceSdk.js +12 -10
  77. package/lib/module/specs/NativeLiveVoiceSdk.js.map +1 -1
  78. package/lib/module/util/Colors.js +14 -11
  79. package/lib/module/util/Colors.js.map +1 -1
  80. package/lib/module/util/Translations.js +46 -21
  81. package/lib/module/util/Translations.js.map +1 -1
  82. package/lib/module/util/freeze.js +26 -0
  83. package/lib/module/util/freeze.js.map +1 -0
  84. package/lib/module/util/logger.js +114 -0
  85. package/lib/module/util/logger.js.map +1 -0
  86. package/lib/typescript/src/components/BrandingView.d.ts +4 -0
  87. package/lib/typescript/src/components/BrandingView.d.ts.map +1 -1
  88. package/lib/typescript/src/components/ChannelView.d.ts +29 -3
  89. package/lib/typescript/src/components/ChannelView.d.ts.map +1 -1
  90. package/lib/typescript/src/components/ErrorView.d.ts +5 -3
  91. package/lib/typescript/src/components/ErrorView.d.ts.map +1 -1
  92. package/lib/typescript/src/components/LiveVoiceSpinner.d.ts +16 -0
  93. package/lib/typescript/src/components/LiveVoiceSpinner.d.ts.map +1 -0
  94. package/lib/typescript/src/components/LiveVoiceView.d.ts +85 -3
  95. package/lib/typescript/src/components/LiveVoiceView.d.ts.map +1 -1
  96. package/lib/typescript/src/components/PasswordPrompt.d.ts +13 -0
  97. package/lib/typescript/src/components/PasswordPrompt.d.ts.map +1 -0
  98. package/lib/typescript/src/components/PlayButtonView.d.ts +12 -329
  99. package/lib/typescript/src/components/PlayButtonView.d.ts.map +1 -1
  100. package/lib/typescript/src/components/ReconnectingView.d.ts +6 -3
  101. package/lib/typescript/src/components/ReconnectingView.d.ts.map +1 -1
  102. package/lib/typescript/src/components/WarningView.d.ts.map +1 -1
  103. package/lib/typescript/src/index.d.ts +15 -144
  104. package/lib/typescript/src/index.d.ts.map +1 -1
  105. package/lib/typescript/src/sdk/Bridge.d.ts +36 -0
  106. package/lib/typescript/src/sdk/Bridge.d.ts.map +1 -0
  107. package/lib/typescript/src/sdk/Event.d.ts +97 -0
  108. package/lib/typescript/src/sdk/Event.d.ts.map +1 -0
  109. package/lib/typescript/src/sdk/Lifecycle.d.ts +191 -0
  110. package/lib/typescript/src/sdk/Lifecycle.d.ts.map +1 -0
  111. package/lib/typescript/src/sdk/LiveVoiceSdk.d.ts +215 -0
  112. package/lib/typescript/src/sdk/LiveVoiceSdk.d.ts.map +1 -0
  113. package/lib/typescript/src/sdk/LiveVoiceState.d.ts +80 -0
  114. package/lib/typescript/src/sdk/LiveVoiceState.d.ts.map +1 -0
  115. package/lib/typescript/src/sdk/LogEntries.d.ts +28 -0
  116. package/lib/typescript/src/sdk/LogEntries.d.ts.map +1 -0
  117. package/lib/typescript/src/sdk/Models.d.ts +114 -0
  118. package/lib/typescript/src/sdk/Models.d.ts.map +1 -0
  119. package/lib/typescript/src/sdk/NativeSdkVersions.d.ts +6 -0
  120. package/lib/typescript/src/sdk/NativeSdkVersions.d.ts.map +1 -0
  121. package/lib/typescript/src/sdk/Observables.d.ts +123 -0
  122. package/lib/typescript/src/sdk/Observables.d.ts.map +1 -0
  123. package/lib/typescript/src/sdk/Passwords.d.ts +72 -0
  124. package/lib/typescript/src/sdk/Passwords.d.ts.map +1 -0
  125. package/lib/typescript/src/sdk/Playback.d.ts +9 -0
  126. package/lib/typescript/src/sdk/Playback.d.ts.map +1 -0
  127. package/lib/typescript/src/specs/NativeLiveVoiceSdk.d.ts +35 -29
  128. package/lib/typescript/src/specs/NativeLiveVoiceSdk.d.ts.map +1 -1
  129. package/lib/typescript/src/util/Colors.d.ts.map +1 -1
  130. package/lib/typescript/src/util/Translations.d.ts +30 -8
  131. package/lib/typescript/src/util/Translations.d.ts.map +1 -1
  132. package/lib/typescript/src/util/freeze.d.ts +6 -0
  133. package/lib/typescript/src/util/freeze.d.ts.map +1 -0
  134. package/lib/typescript/src/util/logger.d.ts +33 -0
  135. package/lib/typescript/src/util/logger.d.ts.map +1 -0
  136. package/livevoice-sdk-react-native.podspec +41 -16
  137. package/package.json +26 -14
  138. package/src/components/BrandingView.tsx +55 -66
  139. package/src/components/ChannelView.tsx +342 -48
  140. package/src/components/ErrorView.tsx +21 -22
  141. package/src/components/LiveVoiceSpinner.tsx +87 -0
  142. package/src/components/LiveVoiceView.tsx +360 -151
  143. package/src/components/PasswordPrompt.tsx +144 -0
  144. package/src/components/PlayButtonView.tsx +177 -279
  145. package/src/components/ReconnectingView.tsx +40 -86
  146. package/src/components/WarningView.tsx +12 -10
  147. package/src/icons/branding-ios.png +0 -0
  148. package/src/icons/camera-off-android.png +0 -0
  149. package/src/icons/camera-off-android@2x.png +0 -0
  150. package/src/icons/camera-off-android@3x.png +0 -0
  151. package/src/icons/cpu-android.png +0 -0
  152. package/src/icons/cpu-android@2x.png +0 -0
  153. package/src/icons/cpu-android@3x.png +0 -0
  154. package/src/icons/cpu-ios.png +0 -0
  155. package/src/icons/cpu-ios@2x.png +0 -0
  156. package/src/icons/cpu-ios@3x.png +0 -0
  157. package/src/icons/lock-android.png +0 -0
  158. package/src/icons/lock-android@2x.png +0 -0
  159. package/src/icons/lock-android@3x.png +0 -0
  160. package/src/icons/lock-ios.png +0 -0
  161. package/src/icons/lock-ios@2x.png +0 -0
  162. package/src/icons/lock-ios@3x.png +0 -0
  163. package/src/icons/mic-off-android.png +0 -0
  164. package/src/icons/mic-off-android@2x.png +0 -0
  165. package/src/icons/mic-off-android@3x.png +0 -0
  166. package/src/icons/mic-slash-ios.png +0 -0
  167. package/src/icons/mic-slash-ios@2x.png +0 -0
  168. package/src/icons/mic-slash-ios@3x.png +0 -0
  169. package/src/icons/video-slash-ios.png +0 -0
  170. package/src/icons/video-slash-ios@2x.png +0 -0
  171. package/src/icons/video-slash-ios@3x.png +0 -0
  172. package/src/index.tsx +105 -252
  173. package/src/sdk/Bridge.ts +259 -0
  174. package/src/sdk/Event.ts +187 -0
  175. package/src/sdk/Lifecycle.ts +366 -0
  176. package/src/sdk/LiveVoiceSdk.ts +384 -0
  177. package/src/sdk/LiveVoiceState.ts +259 -0
  178. package/src/sdk/LogEntries.ts +88 -0
  179. package/src/sdk/Models.ts +129 -0
  180. package/src/sdk/NativeSdkVersions.ts +21 -0
  181. package/src/sdk/Observables.ts +414 -0
  182. package/src/sdk/Passwords.ts +286 -0
  183. package/src/sdk/Playback.ts +30 -0
  184. package/src/specs/NativeLiveVoiceSdk.ts +56 -46
  185. package/src/util/Colors.ts +14 -11
  186. package/src/util/Translations.ts +46 -22
  187. package/src/util/freeze.ts +23 -0
  188. package/src/util/logger.ts +119 -0
  189. package/android/app/build/generated/source/codegen/java/com/facebook/fbreact/specs/NativeLiveVoiceSdkSpec.java +0 -186
  190. package/android/app/build/generated/source/codegen/jni/CMakeLists.txt +0 -28
  191. package/android/app/build/generated/source/codegen/jni/RNLiveVoiceSpec-generated.cpp +0 -235
  192. package/android/app/build/generated/source/codegen/jni/RNLiveVoiceSpec.h +0 -31
  193. package/android/app/build/generated/source/codegen/jni/react/renderer/components/RNLiveVoiceSpec/RNLiveVoiceSpecJSI.h +0 -341
  194. package/android/src/main/java/io/livevoice/react/Mappings.kt +0 -85
  195. package/android/src/main/java/io/livevoice/react/NativeModels.kt +0 -79
  196. package/lib/module/components/AudioOutputSwitchView.js +0 -138
  197. package/lib/module/components/AudioOutputSwitchView.js.map +0 -1
  198. package/lib/module/components/index.js +0 -22
  199. package/lib/module/components/index.js.map +0 -1
  200. package/lib/module/icons/mic.png +0 -0
  201. package/lib/module/util/ForegroundServiceConfig.js +0 -28
  202. package/lib/module/util/ForegroundServiceConfig.js.map +0 -1
  203. package/lib/module/util/PlayingState.js +0 -21
  204. package/lib/module/util/PlayingState.js.map +0 -1
  205. package/lib/module/util/UIState.js +0 -4
  206. package/lib/typescript/src/components/AudioOutputSwitchView.d.ts +0 -6
  207. package/lib/typescript/src/components/AudioOutputSwitchView.d.ts.map +0 -1
  208. package/lib/typescript/src/components/index.d.ts +0 -9
  209. package/lib/typescript/src/components/index.d.ts.map +0 -1
  210. package/lib/typescript/src/util/ForegroundServiceConfig.d.ts +0 -12
  211. package/lib/typescript/src/util/ForegroundServiceConfig.d.ts.map +0 -1
  212. package/lib/typescript/src/util/PlayingState.d.ts +0 -7
  213. package/lib/typescript/src/util/PlayingState.d.ts.map +0 -1
  214. package/lib/typescript/src/util/UIState.d.ts +0 -66
  215. package/lib/typescript/src/util/UIState.d.ts.map +0 -1
  216. package/src/components/AudioOutputSwitchView.tsx +0 -146
  217. package/src/components/index.tsx +0 -19
  218. package/src/icons/mic.png +0 -0
  219. package/src/util/ForegroundServiceConfig.tsx +0 -32
  220. package/src/util/PlayingState.ts +0 -18
  221. package/src/util/UIState.ts +0 -89
@@ -12,27 +12,108 @@
12
12
  //===----------------------------------------------------------------------===//
13
13
 
14
14
  #import "LiveVoiceSdkReactNative.h"
15
- #import "LiveVoiceSDK/LiveVoiceSDK.h"
15
+ // The SDK is reached only through LiveVoiceRNBridge.swift.
16
+ #if __has_include(<livevoice_sdk_react_native/livevoice_sdk_react_native-Swift.h>)
17
+ #import <livevoice_sdk_react_native/livevoice_sdk_react_native-Swift.h>
18
+ #else
19
+ #import "livevoice_sdk_react_native-Swift.h"
20
+ #endif
16
21
  #import "React/RCTVersion.h"
17
22
  #import "__SDK.h"
18
-
19
- // Declare conformance privately
20
- @interface LiveVoiceSdkReactNative () <LiveVoiceDelegate>
23
+ #import <os/log.h>
24
+
25
+ static os_log_t LiveVoiceLogHandle(void) {
26
+ static os_log_t logHandle;
27
+ static dispatch_once_t onceToken;
28
+ dispatch_once(&onceToken, ^{
29
+ logHandle = os_log_create("io.livevoice.react-native", "LiveVoiceSdkReactNative");
30
+ });
31
+ return logHandle;
32
+ }
33
+
34
+ static NSString *LiveVoiceFormatMessage(NSString *event,
35
+ NSDictionary<NSString *, id> *fields) {
36
+ NSMutableArray<NSString *> *parts = [NSMutableArray arrayWithObject:event];
37
+ NSArray<NSString *> *keys =
38
+ [[fields allKeys] sortedArrayUsingSelector:@selector(compare:)];
39
+
40
+ for (NSString *key in keys) {
41
+ id value = fields[key];
42
+ if (value == nil || value == [NSNull null]) {
43
+ continue;
44
+ }
45
+
46
+ [parts addObject:[NSString stringWithFormat:@"%@=%@", key, value]];
47
+ }
48
+
49
+ return [parts componentsJoinedByString:@" "];
50
+ }
51
+
52
+ static void LiveVoiceLogInfo(NSString *event, NSDictionary<NSString *, id> *fields) {
53
+ NSString *message = LiveVoiceFormatMessage(event, fields);
54
+ os_log_with_type(LiveVoiceLogHandle(), OS_LOG_TYPE_INFO, "%{public}s",
55
+ message.UTF8String);
56
+ }
57
+
58
+ @interface LiveVoiceSdkReactNative ()
59
+ // Ownership is protected by @synchronized(self). Never call Swift or a reply
60
+ // while holding it: attaching asynchronously enters the main actor.
61
+ @property(nonatomic, strong, nullable) LiveVoiceRNBridge *liveVoice;
62
+ @property(nonatomic) BOOL runtimeInvalidated;
63
+ @property(nonatomic) BOOL attaching;
64
+ @property(nonatomic, strong) NSMutableArray<void (^)(LiveVoiceRNBridge *_Nullable)> *attachReplies;
65
+ // Events reach JavaScript through the runtime's C++ module, which a reload
66
+ // destroys once `invalidate` returns. The bridge's streams end later, on the
67
+ // main actor, so values still queued must be dropped. This lock makes an
68
+ // emission and `invalidate` exclude each other; nothing else is called under it.
69
+ @property(nonatomic, strong) NSLock *emitLock;
70
+ @property(nonatomic) BOOL emitsStopped;
21
71
  @end
22
72
 
23
73
  @implementation LiveVoiceSdkReactNative
24
74
 
25
75
  RCT_EXPORT_MODULE(LiveVoiceModule)
26
76
 
77
+ - (instancetype)init {
78
+ if ((self = [super init])) _emitLock = [NSLock new];
79
+ return self;
80
+ }
81
+
82
+ /// Runs `emit` unless the runtime went away; `invalidate` waits for one in progress.
83
+ - (void)emitUnlessInvalidated:(void (NS_NOESCAPE ^)(void))emit {
84
+ [self.emitLock lock];
85
+ if (!self.emitsStopped) emit();
86
+ [self.emitLock unlock];
87
+ }
88
+
27
89
  - (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
28
90
  (const facebook::react::ObjCTurboModule::InitParams &)params {
29
91
  return std::make_shared<facebook::react::NativeLiveVoiceSdkSpecJSI>(params);
30
92
  }
31
93
 
32
-
33
-
34
- - (void)initialize:(NSString *_Nullable)androidServiceConfig {
35
- NSLog(@"[SDK] %s", __PRETTY_FUNCTION__);
94
+ static void LiveVoiceReject(RCTPromiseRejectBlock reject, NSString *error) {
95
+ NSDictionary *wire = [NSJSONSerialization JSONObjectWithData:[error dataUsingEncoding:NSUTF8StringEncoding] options:0 error:nil];
96
+ NSString *code = [wire isKindOfClass:[NSDictionary class]] ? wire[@"code"] : nil;
97
+ reject([code isKindOfClass:[NSString class]] ? code : @"generic", error, nil);
98
+ }
99
+
100
+ /// Calls `use` with the attached bridge, attaching it first if needed, or with
101
+ /// nil once the runtime went away.
102
+ - (void)withBridge:(void (^)(LiveVoiceRNBridge *_Nullable))use {
103
+ BOOL invalidated = NO;
104
+ LiveVoiceRNBridge *attached;
105
+ @synchronized(self) {
106
+ invalidated = self.runtimeInvalidated;
107
+ attached = self.liveVoice;
108
+ if (!invalidated && !attached) {
109
+ if (!self.attachReplies) self.attachReplies = [NSMutableArray new];
110
+ [self.attachReplies addObject:use];
111
+ if (self.attaching) return;
112
+ self.attaching = YES;
113
+ }
114
+ }
115
+ if (invalidated) { use(nil); return; }
116
+ if (attached) { use(attached); return; }
36
117
 
37
118
  NSDictionary *versionInfo = RCTGetReactNativeVersion();
38
119
  NSString *major = versionInfo[RCTVersionMajor];
@@ -41,195 +122,216 @@ RCT_EXPORT_MODULE(LiveVoiceModule)
41
122
  NSString *const PLATFORM_VERSION =
42
123
  [NSString stringWithFormat:@"%@.%@.%@", major, minor, patch];
43
124
 
44
- [LiveVoice initializeWithDelegate:self
45
- platform:SDKPlatformReactNative
46
- platformVersion:PLATFORM_VERSION
47
- sdkVersion:SDK_VERSION];
48
- }
49
-
50
- - (void)joinEvent:(nonnull NSString *)joinCode
51
- password:(nullable NSString *)password
52
- apiKey:(nonnull NSString *)apiKey {
53
- NSLog(@"[SDK] %s", __PRETTY_FUNCTION__);
54
- [LiveVoice joinEventWithCode:joinCode password:password apiKey:apiKey];
55
- }
56
-
57
- - (void)leaveEvent {
58
- NSLog(@"[SDK] %s", __PRETTY_FUNCTION__);
59
- [LiveVoice leaveEvent];
60
- }
61
-
62
- - (void)reconnect {
63
- NSLog(@"[SDK] %s", __PRETTY_FUNCTION__);
64
- [LiveVoice reconnect];
65
- }
66
-
67
- #pragma mark - Initial values
68
-
69
- - (nullable NSString *)getCurrentClaims {
70
- NSLog(@"[SDK] %s", __PRETTY_FUNCTION__);
71
- return [LiveVoice currentClaims];
72
- }
73
-
74
- - (nonnull NSString *)getCurrentUiState {
75
- NSLog(@"[SDK] %s", __PRETTY_FUNCTION__);
76
- return [LiveVoice currentViewState];
77
- }
78
-
79
- // true=speaker, false=headphones
80
- - (nonnull NSNumber *)getCurrentAudioState {
81
- NSLog(@"[SDK] %s", __PRETTY_FUNCTION__);
82
- return [NSNumber numberWithBool:[LiveVoice currentAudioOutputIsSpeaker]];
83
- }
84
-
85
- - (nonnull NSString *)getCurrentAvailableSubtitleConfigs {
86
- NSString *current = [LiveVoice currentAvailableSubtitles];
87
- NSLog(@"[SDK] %s %@", __PRETTY_FUNCTION__, current);
88
- return current;
89
- }
90
-
91
- - (nonnull NSString *)getCurrentSubtitles {
92
- NSString *current = [LiveVoice currentSubtitles];
93
- NSLog(@"[SDK] %s %@", __PRETTY_FUNCTION__, current);
94
- return current;
125
+ __weak LiveVoiceSdkReactNative *weakSelf = self;
126
+ [LiveVoiceRNBridge
127
+ startWithReactNativeVersion:PLATFORM_VERSION
128
+ wrapperVersion:SDK_VERSION
129
+ onState:^(NSString *value) {
130
+ LiveVoiceSdkReactNative *module = weakSelf;
131
+ [module emitUnlessInvalidated:^{ [module emitOnState:value]; }];
132
+ }
133
+ onPasswordRequest:^(NSString *value) {
134
+ LiveVoiceSdkReactNative *module = weakSelf;
135
+ [module emitUnlessInvalidated:^{ [module emitOnPasswordRequest:value]; }];
136
+ }
137
+ onPasswordRequestCancelled:^(NSString *value) {
138
+ LiveVoiceSdkReactNative *module = weakSelf;
139
+ [module emitUnlessInvalidated:^{ [module emitOnPasswordRequestCancelled:value]; }];
140
+ }
141
+ onPasswordStoreRequest:^(NSString *value) {
142
+ LiveVoiceSdkReactNative *module = weakSelf;
143
+ [module emitUnlessInvalidated:^{ [module emitOnPasswordStoreRequest:value]; }];
144
+ }
145
+ onLogEntry:^(NSString *value) {
146
+ LiveVoiceSdkReactNative *module = weakSelf;
147
+ [module emitUnlessInvalidated:^{ [module emitOnLogEntry:value]; }];
148
+ }
149
+ completion:^(LiveVoiceRNBridge *created) {
150
+ LiveVoiceSdkReactNative *module = weakSelf;
151
+ if (!module) { [created invalidate]; return; }
152
+ NSArray<void (^)(LiveVoiceRNBridge *_Nullable)> *replies;
153
+ BOOL invalidated;
154
+ @synchronized(module) {
155
+ invalidated = module.runtimeInvalidated;
156
+ if (!invalidated) module.liveVoice = created;
157
+ module.attaching = NO;
158
+ replies = [module.attachReplies copy];
159
+ module.attachReplies = nil;
160
+ }
161
+ if (invalidated) [created invalidate];
162
+ else LiveVoiceLogInfo(@"LV_INIT", @{@"platformVersion" : PLATFORM_VERSION});
163
+ for (void (^pending)(LiveVoiceRNBridge *_Nullable) in replies) pending(invalidated ? nil : created);
164
+ }];
165
+ }
166
+
167
+ - (void)initialize:(NSString *)configuration
168
+ resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
169
+ [self withBridge:^(LiveVoiceRNBridge *bridge) {
170
+ if (bridge == nil) { LiveVoiceReject(reject, [LiveVoiceRNBridge errorJSONWithCode:@"cancelled"]); return; }
171
+ [bridge initializeWithConfiguration:configuration completion:^(NSString *snapshot, NSString *error) {
172
+ if (error != nil) LiveVoiceReject(reject, error);
173
+ else resolve(snapshot);
174
+ }];
175
+ }];
176
+ }
177
+
178
+ - (void)execute:(NSString *)command payload:(NSString *)arguments
179
+ resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
180
+ LiveVoiceRNBridge *bridge;
181
+ BOOL invalidated;
182
+ @synchronized(self) { bridge = self.liveVoice; invalidated = self.runtimeInvalidated; }
183
+ if (bridge == nil) {
184
+ LiveVoiceReject(reject, [LiveVoiceRNBridge errorJSONWithCode:invalidated ? @"cancelled" : @"not_initialized"]);
185
+ return;
186
+ }
187
+ [bridge executeWithName:command arguments:arguments completion:^(NSString *value, NSString *error) {
188
+ if (error != nil) LiveVoiceReject(reject, error);
189
+ else resolve(value ?: @"null");
190
+ }];
191
+ }
192
+
193
+ - (NSString *)getErrorMessages {
194
+ return LiveVoiceRNBridge.errorMessages;
195
+ }
196
+
197
+ // Works before `initialize`: attaches the bridge first if needed, so the
198
+ // preference reaches native and the snapshot later carries it. Ignored once
199
+ // the runtime went away.
200
+ - (void)setAudioOutput:(NSString *)payload {
201
+ [self withBridge:^(LiveVoiceRNBridge *bridge) {
202
+ [bridge setAudioOutput:payload];
203
+ }];
204
+ }
205
+
206
+ - (void)writeLogEntry:(NSString *)payload {
207
+ [LiveVoiceRNBridge writeLogEntry:payload];
208
+ }
209
+
210
+ - (void)answerPasswordRequest:(NSString *)payload {
211
+ [[self bridgeSnapshot] answerPasswordRequest:payload];
212
+ }
213
+
214
+ - (void)answerPasswordStoreRequest:(NSString *)payload {
215
+ [[self bridgeSnapshot] answerPasswordStoreRequest:payload];
216
+ }
217
+
218
+ - (void)setPasswordStore:(NSString *)payload {
219
+ [[self bridgeSnapshot] setPasswordStore:payload];
220
+ }
221
+
222
+ - (LiveVoiceRNBridge *)bridgeSnapshot {
223
+ @synchronized(self) { return self.runtimeInvalidated ? nil : self.liveVoice; }
224
+ }
225
+
226
+ - (void)invalidate {
227
+ [self.emitLock lock];
228
+ self.emitsStopped = YES;
229
+ [self.emitLock unlock];
230
+ LiveVoiceRNBridge *bridge;
231
+ NSArray<void (^)(LiveVoiceRNBridge *_Nullable)> *replies;
232
+ @synchronized(self) {
233
+ self.runtimeInvalidated = YES;
234
+ bridge = self.liveVoice;
235
+ self.liveVoice = nil;
236
+ replies = [self.attachReplies copy];
237
+ self.attachReplies = nil;
238
+ }
239
+ [bridge invalidate];
240
+ for (void (^pending)(LiveVoiceRNBridge *_Nullable) in replies) pending(nil);
95
241
  }
96
242
 
97
243
  #pragma mark - Actions
98
244
 
99
- - (void)setLiveVoiceUseSpeaker:(BOOL)useSpeaker {
100
- NSLog(@"[SDK] %s %@", __PRETTY_FUNCTION__,
101
- useSpeaker ? @"speaker" : @"receiver");
102
- [LiveVoice setAudioOutputToSpeaker:useSpeaker];
103
- }
104
-
105
- - (void)startChannel:(double)channelID {
106
- NSLog(@"[SDK] %s %d", __PRETTY_FUNCTION__, (int)channelID);
107
- [LiveVoice startWithChannelID:channelID];
108
- }
109
-
110
- - (void)stopChannel {
111
- NSLog(@"[SDK] %s", __PRETTY_FUNCTION__);
112
- [LiveVoice stop];
113
- }
114
-
115
- #pragma mark - Subtitles
116
-
117
- - (void)startSubtitles:(double)channelId {
118
- NSLog(@"[SDK] %s channel: %f", __PRETTY_FUNCTION__, channelId);
119
- NSNumber *_Nullable optionalChannelID =
120
- (channelId == -1) ? nil : [NSNumber numberWithLongLong:channelId];
121
- [LiveVoice startSubtitlesWithChannelID:optionalChannelID];
245
+ - (void)openLiveVoiceWebsite {
246
+ [LiveVoiceRNBridge openLiveVoiceWebsite];
122
247
  }
123
248
 
124
- - (void)stopSubtitles {
125
- NSLog(@"[SDK] %s", __PRETTY_FUNCTION__);
126
- [LiveVoice stopSubtitles];
249
+ - (nonnull NSString *)getSdkVersion {
250
+ return SDK_VERSION;
127
251
  }
128
252
 
129
- - (void)openLiveVoiceWebsite {
130
- [LiveVoice openLiveVoiceWebsite];
253
+ - (nonnull NSString *)getNativeSdkVersion {
254
+ return LiveVoiceRNBridge.nativeSdkVersion;
131
255
  }
132
256
 
133
257
  #pragma mark - Translations
134
258
 
135
259
  - (nonnull NSString *)channelStatusOffline {
136
- return [Translations channel_status_offline];
260
+ return [LiveVoiceRNBridge translation:@"channel_status_offline" seconds:0];
137
261
  }
138
262
 
139
263
  - (nonnull NSString *)errorScreenRetrying {
140
- return [Translations error_screen_retrying];
264
+ return [LiveVoiceRNBridge translation:@"error_screen_retrying" seconds:0];
141
265
  }
142
266
 
143
267
  - (nonnull NSString *)errorScreenRetryingIn:(double)seconds {
144
- return [Translations error_screen_retrying_in:(int)seconds];
145
- }
146
-
147
- - (nonnull NSString *)sdkErrorGeneric {
148
- return [Translations sdk_error_generic];
149
- }
150
-
151
- - (nonnull NSString *)sdkErrorInactive {
152
- return [Translations sdk_error_inactive];
153
- }
154
-
155
- - (nonnull NSString *)sdkErrorInvalidApiKey {
156
- return [Translations sdk_error_invalid_api_key];
157
- }
158
-
159
- - (nonnull NSString *)sdkErrorListenerLimitReached {
160
- return [Translations sdk_error_listener_limit_reached];
161
- }
162
-
163
- - (nonnull NSString *)sdkErrorNoNetwork {
164
- return [Translations sdk_error_no_network];
165
- }
166
-
167
- - (nonnull NSString *)sdkErrorNotFound {
168
- return [Translations sdk_error_not_found];
169
- }
170
-
171
- - (nonnull NSString *)sdkErrorRequestFailed:(double)errorCode {
172
- return [Translations
173
- sdk_error_request_failed:[NSString stringWithFormat:@"%1.0f", errorCode]];
174
- }
175
-
176
- - (nonnull NSString *)sdkErrorWrongPassword {
177
- return [Translations sdk_error_wrong_password];
268
+ return [LiveVoiceRNBridge translation:@"error_screen_retrying_in" seconds:(NSInteger)seconds];
178
269
  }
179
270
 
180
271
  - (nonnull NSString *)sdkNoMatchingChannels {
181
- return [Translations sdk_no_matching_channels];
272
+ return [LiveVoiceRNBridge translation:@"sdk_no_matching_channels" seconds:0];
182
273
  }
183
274
 
184
275
  - (nonnull NSString *)streamingByTitle {
185
- return [Translations streaming_by_title];
276
+ return [LiveVoiceRNBridge translation:@"streaming_by_title" seconds:0];
186
277
  }
187
278
 
188
279
  - (nonnull NSString *)accessibilityChannelPlay {
189
- return [Translations a11y_channel_play];
280
+ return [LiveVoiceRNBridge translation:@"a11y_channel_play" seconds:0];
190
281
  }
191
282
 
192
283
  - (nonnull NSString *)accessibilityChannelStatusMuted {
193
- return [Translations a11y_channel_status_muted];
284
+ return [LiveVoiceRNBridge translation:@"a11y_channel_status_muted" seconds:0];
194
285
  }
195
286
 
196
287
  - (nonnull NSString *)accessibilityChannelStop {
197
- return [Translations a11y_channel_stop];
288
+ return [LiveVoiceRNBridge translation:@"a11y_channel_stop" seconds:0];
198
289
  }
199
290
 
200
291
  - (nonnull NSString *)isAiChannelStatusMessage {
201
- return [Translations channel_status_is_ai];
292
+ return [LiveVoiceRNBridge translation:@"channel_status_is_ai" seconds:0];
202
293
  }
203
294
 
204
295
  - (nonnull NSString *)noChannels {
205
- return [Translations sdk_no_matching_channels];
296
+ return [LiveVoiceRNBridge translation:@"no_channels" seconds:0];
206
297
  }
207
298
 
208
299
  - (nonnull NSString *)errorRetryNowButton {
209
- return [Translations action_retry_now];
300
+ return [LiveVoiceRNBridge translation:@"action_retry_now" seconds:0];
301
+ }
302
+
303
+ #pragma mark - Password prompt
304
+
305
+ - (nonnull NSString *)passwordPromptTitle {
306
+ return [LiveVoiceRNBridge translation:@"password_prompt_title" seconds:0];
307
+ }
308
+
309
+ - (nonnull NSString *)passwordPromptChannelMessage {
310
+ return [LiveVoiceRNBridge translation:@"password_prompt_channel_message" seconds:0];
210
311
  }
211
312
 
212
- #pragma mark - LiveVoiceDelegate
313
+ - (nonnull NSString *)passwordPromptEventMessage {
314
+ return [LiveVoiceRNBridge translation:@"password_prompt_event_message" seconds:0];
315
+ }
316
+
317
+ - (nonnull NSString *)passwordPromptWrongPassword {
318
+ return [LiveVoiceRNBridge translation:@"password_prompt_wrong_password" seconds:0];
319
+ }
213
320
 
214
- - (void)viewStateDidChange:(nonnull NSString *)serializedState {
215
- NSLog(@"[SDK] %s", __PRETTY_FUNCTION__);
216
- [self emitOnUiStateChanged:serializedState];
321
+ - (nonnull NSString *)passwordPromptField {
322
+ return [LiveVoiceRNBridge translation:@"password_prompt_field" seconds:0];
217
323
  }
218
324
 
219
- - (void)audioOutputDidChange:(BOOL)useSpeaker {
220
- NSLog(@"[SDK] %s %@", __PRETTY_FUNCTION__,
221
- useSpeaker ? @"speaker" : @"receiver");
222
- [self emitOnAudioOutputChanged:useSpeaker];
325
+ - (nonnull NSString *)passwordPromptCancelButton {
326
+ return [LiveVoiceRNBridge translation:@"password_prompt_cancel_button" seconds:0];
223
327
  }
224
328
 
225
- - (void)availableSubtitlesDidChange:(NSString *)available {
226
- NSLog(@"[SDK] %s %@", __PRETTY_FUNCTION__, available);
227
- [self emitOnAvailableSubtitleConfigsChanged:available];
329
+ - (nonnull NSString *)passwordPromptChannelConfirmButton {
330
+ return [LiveVoiceRNBridge translation:@"password_prompt_channel_confirm_button" seconds:0];
228
331
  }
229
332
 
230
- - (void)subtitlesDidChange:(NSString *)subtitles {
231
- NSLog(@"[SDK] %s %@", __PRETTY_FUNCTION__, subtitles);
232
- [self emitOnSubtitlesChanged:subtitles];
333
+ - (nonnull NSString *)passwordPromptEventConfirmButton {
334
+ return [LiveVoiceRNBridge translation:@"password_prompt_event_confirm_button" seconds:0];
233
335
  }
234
336
 
235
337
  @end
package/ios/__SDK.h CHANGED
@@ -1,4 +1,18 @@
1
- // AUTO-GENERATED FILE
1
+ //===----------------------------------------------------------------------===//
2
+ //
3
+ // This source file is part of the LiveVoice SDK project
4
+ //
5
+ // Copyright (c) LiveVoice GmbH
6
+ // Licensed under the MIT license
7
+ //
8
+ // See LICENSE for license information
9
+ //
10
+ // SPDX-License-Identifier: MIT
11
+ //
12
+ //===----------------------------------------------------------------------===//
13
+
14
+ // GENERATED CODE - DO NOT MODIFY BY HAND.
15
+ // Generated by tool/generate-native-versions.mjs from package.json.
2
16
  #import <Foundation/Foundation.h>
3
17
 
4
- NSString* const SDK_VERSION = @"2.0.0";
18
+ NSString* const SDK_VERSION = @"3.0.0";