livevoice-sdk-react-native 1.0.2 → 2.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 (188) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +5 -5
  3. package/android/{generated/java/io/livevoice/react → app/build/generated/source/codegen/java/com/facebook/fbreact/specs}/NativeLiveVoiceSdkSpec.java +2 -2
  4. package/android/{generated → app/build/generated/source/codegen}/jni/CMakeLists.txt +1 -9
  5. package/android/{generated → app/build/generated/source/codegen}/jni/RNLiveVoiceSpec-generated.cpp +3 -3
  6. package/android/app/build/generated/source/codegen/jni/react/renderer/components/RNLiveVoiceSpec/RNLiveVoiceSpecJSI.h +341 -0
  7. package/android/build.gradle +41 -84
  8. package/android/gradle.properties +10 -6
  9. package/android/src/main/java/io/livevoice/react/LiveVoiceModule.kt +17 -16
  10. package/android/src/main/java/io/livevoice/react/LiveVoiceSdkReactNativePackage.kt +12 -13
  11. package/android/src/main/java/io/livevoice/react/Mappings.kt +36 -5
  12. package/android/src/main/java/io/livevoice/react/NativeModels.kt +2 -0
  13. package/android/src/main/java/io/livevoice/react/__SDK.kt +1 -1
  14. package/ios/LiveVoiceSdkReactNative.h +5 -5
  15. package/ios/{LivevoiceSdkReactNative.mm → LiveVoiceSdkReactNative.mm} +59 -74
  16. package/ios/__SDK.h +1 -1
  17. package/lib/module/components/AudioOutputSwitchView.js +5 -1
  18. package/lib/module/components/AudioOutputSwitchView.js.map +1 -1
  19. package/lib/module/components/ChannelView.js +14 -38
  20. package/lib/module/components/ChannelView.js.map +1 -1
  21. package/lib/module/components/LiveVoiceView.js +61 -26
  22. package/lib/module/components/LiveVoiceView.js.map +1 -1
  23. package/lib/module/components/PlayButtonView.js +243 -84
  24. package/lib/module/components/PlayButtonView.js.map +1 -1
  25. package/lib/module/icons/captions@1x.png +0 -0
  26. package/lib/module/icons/captions@2x.png +0 -0
  27. package/lib/module/icons/pause@1x.png +0 -0
  28. package/lib/module/icons/pause@2x.png +0 -0
  29. package/lib/module/icons/play@1x.png +0 -0
  30. package/lib/module/icons/play@2x.png +0 -0
  31. package/lib/module/index.js +27 -21
  32. package/lib/module/index.js.map +1 -1
  33. package/lib/module/specs/NativeLiveVoiceSdk.js +4 -0
  34. package/lib/module/specs/NativeLiveVoiceSdk.js.map +1 -1
  35. package/lib/module/util/Colors.js +2 -1
  36. package/lib/module/util/Colors.js.map +1 -1
  37. package/lib/typescript/package.json +1 -0
  38. package/lib/typescript/src/components/AudioOutputSwitchView.d.ts.map +1 -0
  39. package/lib/typescript/src/components/BrandingView.d.ts.map +1 -0
  40. package/lib/typescript/{commonjs/src → src}/components/ChannelView.d.ts +4 -2
  41. package/lib/typescript/src/components/ChannelView.d.ts.map +1 -0
  42. package/lib/typescript/src/components/ErrorView.d.ts.map +1 -0
  43. package/lib/typescript/src/components/LiveVoiceView.d.ts.map +1 -0
  44. package/lib/typescript/src/components/PlayButtonView.d.ts +341 -0
  45. package/lib/typescript/src/components/PlayButtonView.d.ts.map +1 -0
  46. package/lib/typescript/src/components/ReconnectingView.d.ts.map +1 -0
  47. package/lib/typescript/src/components/WarningView.d.ts.map +1 -0
  48. package/lib/typescript/src/components/index.d.ts.map +1 -0
  49. package/lib/typescript/{commonjs/src → src}/index.d.ts +30 -18
  50. package/lib/typescript/src/index.d.ts.map +1 -0
  51. package/lib/typescript/{commonjs/src → src}/specs/NativeLiveVoiceSdk.d.ts +3 -3
  52. package/lib/typescript/src/specs/NativeLiveVoiceSdk.d.ts.map +1 -0
  53. package/lib/typescript/{commonjs/src → src}/util/Colors.d.ts +2 -1
  54. package/lib/typescript/src/util/Colors.d.ts.map +1 -0
  55. package/lib/typescript/src/util/ForegroundServiceConfig.d.ts.map +1 -0
  56. package/lib/typescript/src/util/PlayingState.d.ts.map +1 -0
  57. package/lib/typescript/src/util/Translations.d.ts.map +1 -0
  58. package/lib/typescript/{module/src → src}/util/UIState.d.ts +22 -1
  59. package/lib/typescript/src/util/UIState.d.ts.map +1 -0
  60. package/livevoice-sdk-react-native.podspec +6 -27
  61. package/package.json +33 -123
  62. package/src/components/AudioOutputSwitchView.tsx +10 -9
  63. package/src/components/ChannelView.tsx +18 -25
  64. package/src/components/LiveVoiceView.tsx +143 -83
  65. package/src/components/PlayButtonView.tsx +280 -87
  66. package/src/icons/captions@1x.png +0 -0
  67. package/src/icons/captions@2x.png +0 -0
  68. package/src/icons/pause@1x.png +0 -0
  69. package/src/icons/pause@2x.png +0 -0
  70. package/src/icons/play@1x.png +0 -0
  71. package/src/icons/play@2x.png +0 -0
  72. package/src/index.tsx +99 -75
  73. package/src/specs/NativeLiveVoiceSdk.ts +7 -5
  74. package/src/util/Colors.ts +3 -1
  75. package/src/util/UIState.ts +25 -1
  76. package/android/generated/jni/react/renderer/components/RNLiveVoiceSpec/RNLiveVoiceSpecJSI-generated.cpp +0 -245
  77. package/android/generated/jni/react/renderer/components/RNLiveVoiceSpec/RNLiveVoiceSpecJSI.h +0 -398
  78. package/android/src/main/AndroidManifest.xml +0 -3
  79. package/ios/generated/RNLiveVoiceSpec/RNLiveVoiceSpec-generated.mm +0 -292
  80. package/ios/generated/RNLiveVoiceSpec/RNLiveVoiceSpec.h +0 -101
  81. package/ios/generated/RNLiveVoiceSpecJSI-generated.cpp +0 -245
  82. package/ios/generated/RNLiveVoiceSpecJSI.h +0 -398
  83. package/lib/commonjs/components/AudioOutputSwitchView.js +0 -140
  84. package/lib/commonjs/components/AudioOutputSwitchView.js.map +0 -1
  85. package/lib/commonjs/components/BrandingView.js +0 -78
  86. package/lib/commonjs/components/BrandingView.js.map +0 -1
  87. package/lib/commonjs/components/ChannelView.js +0 -117
  88. package/lib/commonjs/components/ChannelView.js.map +0 -1
  89. package/lib/commonjs/components/ErrorView.js +0 -88
  90. package/lib/commonjs/components/ErrorView.js.map +0 -1
  91. package/lib/commonjs/components/LiveVoiceView.js +0 -95
  92. package/lib/commonjs/components/LiveVoiceView.js.map +0 -1
  93. package/lib/commonjs/components/PlayButtonView.js +0 -161
  94. package/lib/commonjs/components/PlayButtonView.js.map +0 -1
  95. package/lib/commonjs/components/ReconnectingView.js +0 -109
  96. package/lib/commonjs/components/ReconnectingView.js.map +0 -1
  97. package/lib/commonjs/components/WarningView.js +0 -58
  98. package/lib/commonjs/components/WarningView.js.map +0 -1
  99. package/lib/commonjs/components/index.js +0 -94
  100. package/lib/commonjs/components/index.js.map +0 -1
  101. package/lib/commonjs/icons/branding.png +0 -0
  102. package/lib/commonjs/icons/cpu.png +0 -0
  103. package/lib/commonjs/icons/headphones.png +0 -0
  104. package/lib/commonjs/icons/mic.png +0 -0
  105. package/lib/commonjs/icons/pause.png +0 -0
  106. package/lib/commonjs/icons/play.png +0 -0
  107. package/lib/commonjs/icons/speaker.png +0 -0
  108. package/lib/commonjs/index.js +0 -319
  109. package/lib/commonjs/index.js.map +0 -1
  110. package/lib/commonjs/specs/NativeLiveVoiceSdk.js +0 -19
  111. package/lib/commonjs/specs/NativeLiveVoiceSdk.js.map +0 -1
  112. package/lib/commonjs/util/Colors.js +0 -30
  113. package/lib/commonjs/util/Colors.js.map +0 -1
  114. package/lib/commonjs/util/ForegroundServiceConfig.js +0 -33
  115. package/lib/commonjs/util/ForegroundServiceConfig.js.map +0 -1
  116. package/lib/commonjs/util/PlayingState.js +0 -24
  117. package/lib/commonjs/util/PlayingState.js.map +0 -1
  118. package/lib/commonjs/util/Translations.js +0 -47
  119. package/lib/commonjs/util/Translations.js.map +0 -1
  120. package/lib/commonjs/util/UIState.js +0 -6
  121. package/lib/commonjs/util/UIState.js.map +0 -1
  122. package/lib/module/icons/pause.png +0 -0
  123. package/lib/module/icons/play.png +0 -0
  124. package/lib/typescript/commonjs/package.json +0 -1
  125. package/lib/typescript/commonjs/src/components/AudioOutputSwitchView.d.ts.map +0 -1
  126. package/lib/typescript/commonjs/src/components/BrandingView.d.ts.map +0 -1
  127. package/lib/typescript/commonjs/src/components/ChannelView.d.ts.map +0 -1
  128. package/lib/typescript/commonjs/src/components/ErrorView.d.ts.map +0 -1
  129. package/lib/typescript/commonjs/src/components/LiveVoiceView.d.ts.map +0 -1
  130. package/lib/typescript/commonjs/src/components/PlayButtonView.d.ts +0 -146
  131. package/lib/typescript/commonjs/src/components/PlayButtonView.d.ts.map +0 -1
  132. package/lib/typescript/commonjs/src/components/ReconnectingView.d.ts.map +0 -1
  133. package/lib/typescript/commonjs/src/components/WarningView.d.ts.map +0 -1
  134. package/lib/typescript/commonjs/src/components/index.d.ts.map +0 -1
  135. package/lib/typescript/commonjs/src/index.d.ts.map +0 -1
  136. package/lib/typescript/commonjs/src/specs/NativeLiveVoiceSdk.d.ts.map +0 -1
  137. package/lib/typescript/commonjs/src/util/Colors.d.ts.map +0 -1
  138. package/lib/typescript/commonjs/src/util/ForegroundServiceConfig.d.ts.map +0 -1
  139. package/lib/typescript/commonjs/src/util/PlayingState.d.ts.map +0 -1
  140. package/lib/typescript/commonjs/src/util/Translations.d.ts.map +0 -1
  141. package/lib/typescript/commonjs/src/util/UIState.d.ts +0 -45
  142. package/lib/typescript/commonjs/src/util/UIState.d.ts.map +0 -1
  143. package/lib/typescript/module/src/components/AudioOutputSwitchView.d.ts +0 -6
  144. package/lib/typescript/module/src/components/AudioOutputSwitchView.d.ts.map +0 -1
  145. package/lib/typescript/module/src/components/BrandingView.d.ts +0 -6
  146. package/lib/typescript/module/src/components/BrandingView.d.ts.map +0 -1
  147. package/lib/typescript/module/src/components/ChannelView.d.ts +0 -13
  148. package/lib/typescript/module/src/components/ChannelView.d.ts.map +0 -1
  149. package/lib/typescript/module/src/components/ErrorView.d.ts +0 -9
  150. package/lib/typescript/module/src/components/ErrorView.d.ts.map +0 -1
  151. package/lib/typescript/module/src/components/LiveVoiceView.d.ts +0 -6
  152. package/lib/typescript/module/src/components/LiveVoiceView.d.ts.map +0 -1
  153. package/lib/typescript/module/src/components/PlayButtonView.d.ts +0 -146
  154. package/lib/typescript/module/src/components/PlayButtonView.d.ts.map +0 -1
  155. package/lib/typescript/module/src/components/ReconnectingView.d.ts +0 -9
  156. package/lib/typescript/module/src/components/ReconnectingView.d.ts.map +0 -1
  157. package/lib/typescript/module/src/components/WarningView.d.ts +0 -8
  158. package/lib/typescript/module/src/components/WarningView.d.ts.map +0 -1
  159. package/lib/typescript/module/src/components/index.d.ts +0 -9
  160. package/lib/typescript/module/src/components/index.d.ts.map +0 -1
  161. package/lib/typescript/module/src/index.d.ts +0 -133
  162. package/lib/typescript/module/src/index.d.ts.map +0 -1
  163. package/lib/typescript/module/src/specs/NativeLiveVoiceSdk.d.ts +0 -48
  164. package/lib/typescript/module/src/specs/NativeLiveVoiceSdk.d.ts.map +0 -1
  165. package/lib/typescript/module/src/util/Colors.d.ts +0 -13
  166. package/lib/typescript/module/src/util/Colors.d.ts.map +0 -1
  167. package/lib/typescript/module/src/util/ForegroundServiceConfig.d.ts +0 -12
  168. package/lib/typescript/module/src/util/ForegroundServiceConfig.d.ts.map +0 -1
  169. package/lib/typescript/module/src/util/PlayingState.d.ts +0 -7
  170. package/lib/typescript/module/src/util/PlayingState.d.ts.map +0 -1
  171. package/lib/typescript/module/src/util/Translations.d.ts +0 -22
  172. package/lib/typescript/module/src/util/Translations.d.ts.map +0 -1
  173. package/lib/typescript/module/src/util/UIState.d.ts.map +0 -1
  174. package/react-native.config.js +0 -12
  175. package/src/icons/pause.png +0 -0
  176. package/src/icons/play.png +0 -0
  177. /package/android/{generated → app/build/generated/source/codegen}/jni/RNLiveVoiceSpec.h +0 -0
  178. /package/lib/{typescript/module → module}/package.json +0 -0
  179. /package/lib/typescript/{commonjs/src → src}/components/AudioOutputSwitchView.d.ts +0 -0
  180. /package/lib/typescript/{commonjs/src → src}/components/BrandingView.d.ts +0 -0
  181. /package/lib/typescript/{commonjs/src → src}/components/ErrorView.d.ts +0 -0
  182. /package/lib/typescript/{commonjs/src → src}/components/LiveVoiceView.d.ts +0 -0
  183. /package/lib/typescript/{commonjs/src → src}/components/ReconnectingView.d.ts +0 -0
  184. /package/lib/typescript/{commonjs/src → src}/components/WarningView.d.ts +0 -0
  185. /package/lib/typescript/{commonjs/src → src}/components/index.d.ts +0 -0
  186. /package/lib/typescript/{commonjs/src → src}/util/ForegroundServiceConfig.d.ts +0 -0
  187. /package/lib/typescript/{commonjs/src → src}/util/PlayingState.d.ts +0 -0
  188. /package/lib/typescript/{commonjs/src → src}/util/Translations.d.ts +0 -0
@@ -9,112 +9,172 @@
9
9
  * SPDX-License-Identifier: MIT
10
10
  */
11
11
 
12
- import {
13
- type UiState,
14
- type AvailableSubtitleConfigs,
15
- getCurrentUiState,
16
- onUiStateChanged,
17
- startChannel,
18
- stopChannel,
19
- reconnect,
20
- onAvailableSubtitleConfigsChanged,
12
+ import {
13
+ type UiState,
14
+ type AvailableSubtitle,
15
+ getCurrentUiState,
16
+ onUiStateChanged,
17
+ startChannel,
18
+ stopChannel,
19
+ reconnect,
20
+ onAvailableSubtitleConfigsChanged,
21
21
  onSubtitlesChanged,
22
- getCurrentClaims,
23
- BrandingView,
24
- ErrorView,
25
- ReconnectingView
26
- } from 'livevoice-sdk-react-native';
22
+ getCurrentClaims,
23
+ BrandingView,
24
+ ErrorView,
25
+ ReconnectingView,
26
+ startSubtitles,
27
+ } from "livevoice-sdk-react-native";
27
28
 
28
- import { useEffect, useState } from 'react';
29
- import { View, ActivityIndicator } from 'react-native';
29
+ import { PlayingState } from "../util/PlayingState";
30
30
 
31
- import { COLORS } from '../util/Colors';
32
- import { type Channel } from '../util/UIState';
33
- import { ChannelView } from './ChannelView';
31
+ import { useEffect, useState } from "react";
32
+ import { View, ActivityIndicator } from "react-native";
33
+
34
+ import { COLORS } from "../util/Colors";
35
+ import { type Channel } from "../util/UIState";
36
+ import { ChannelView } from "./ChannelView";
34
37
 
35
38
  export interface LiveVoiceViewProps {
36
39
  isDarkMode?: boolean;
37
40
  }
38
41
 
39
42
  export const LiveVoiceView: React.FC<LiveVoiceViewProps> = ({ isDarkMode }) => {
40
- const [uiState, setUiState] = useState<UiState>((() => getCurrentUiState()))
41
-
42
- useEffect(
43
- () => { onUiStateChanged((data: UiState) => { setUiState(data); }); },
44
- []
45
- );
46
-
47
- useEffect(
48
- () => {
49
- onAvailableSubtitleConfigsChanged((data: AvailableSubtitleConfigs) => {
50
- console.log('available subtitles changed!' + JSON.stringify(data))
43
+ const [uiState, setUiState] = useState<UiState>(() => getCurrentUiState());
44
+
45
+ useEffect(() => {
46
+ let subscription: { remove: () => void } | undefined = onUiStateChanged(
47
+ (data: UiState) => {
48
+ setUiState(data);
49
+ },
50
+ );
51
+ return () => {
52
+ subscription?.remove();
53
+ subscription = undefined;
54
+ };
55
+ }, []);
56
+
57
+ useEffect(() => {
58
+ let subscription: { remove: () => void } | undefined =
59
+ onAvailableSubtitleConfigsChanged((data: [AvailableSubtitle]) => {
60
+ console.log(
61
+ "available subtitles changed! …" + JSON.stringify(data).slice(-20),
62
+ );
51
63
  });
52
- },
53
- []
54
- );
64
+ return () => {
65
+ subscription?.remove();
66
+ subscription = undefined;
67
+ };
68
+ }, []);
69
+
70
+ useEffect(() => {
71
+ let subscription: { remove: () => void } | undefined = onSubtitlesChanged(
72
+ (data: [String]) => {
73
+ console.log(
74
+ "available subtitles changed! …" + JSON.stringify(data).slice(-20),
75
+ );
76
+ },
77
+ );
78
+ return () => {
79
+ subscription?.remove();
80
+ subscription = undefined;
81
+ };
82
+ }, []);
83
+
84
+ const claims = getCurrentClaims();
55
85
 
86
+ switch (uiState.type) {
87
+ case "ready":
88
+ const backgroundColor = isDarkMode ? COLORS.cardBgDark : COLORS.cardBg;
89
+ const dividerColor = isDarkMode ? COLORS.dividerDark : COLORS.divider;
56
90
 
57
- useEffect(
58
- () => {
59
- onSubtitlesChanged((data: [String]) => {
60
- console.log('subtitles changed!' + JSON.stringify(data))
61
- });
62
- },
63
- []
64
- );
65
-
66
- const claims = getCurrentClaims()
91
+ return (
92
+ <View style={{ width: "100%" }}>
93
+ <View
94
+ style={{
95
+ backgroundColor: backgroundColor,
96
+ borderRadius: 8,
97
+ overflow: "hidden",
98
+ }}
99
+ >
100
+ {uiState.channels.map((channel: Channel, index: number) => (
101
+ <View key={index}>
102
+ <ChannelView
103
+ playingState={channel.playingState}
104
+ isDarkMode={isDarkMode}
105
+ muted={channel.isAudioMuted}
106
+ isOnline={channel.isOnline}
107
+ hasAudio={channel.hasAudio}
108
+ hasSubtitles={channel.hasSubtitles}
109
+ channelName={channel.name}
110
+ onAudioPress={() =>
111
+ channel.playingState === PlayingState.PLAYING
112
+ ? stopChannel()
113
+ : startChannel(channel.id)
114
+ }
115
+ onSubtitlesPress={() => startSubtitles(channel.id)}
116
+ />
117
+ {index < uiState.channels.length - 1 && (
118
+ <View
119
+ style={{
120
+ height: 1,
121
+ backgroundColor: dividerColor,
122
+ marginHorizontal: 10,
123
+ }}
124
+ />
125
+ )}
126
+ </View>
127
+ ))}
128
+ </View>
129
+
130
+ {(claims === null || !claims.hideBranding) && (
131
+ <BrandingView isDarkMode={isDarkMode} />
132
+ )}
133
+ </View>
134
+ );
67
135
 
68
- switch (uiState.type) {
69
- case 'ready':
70
- return (<View>
71
- {uiState.channels.map((channel: Channel, index: number) => (
72
- <ChannelView
73
- key={index}
74
- playingState={channel.playingState}
75
- isDarkMode={isDarkMode}
76
- muted={channel.isAudioMuted}
77
- isOnline={channel.isOnline}
78
- aiSpeaker={channel.isAiSpeaker}
79
- channelName={channel.name}
80
- onPress={() => channel.playingState === 'PLAYING' ? stopChannel() : startChannel(channel.id)}
81
- />
82
- ))}
83
-
84
- {
85
- (claims === null || !claims.hideBranding) && (
86
- <BrandingView isDarkMode={isDarkMode} />)
87
- }
88
- </View>)
89
-
90
- case 'loading':
91
- const backgroundColor = isDarkMode ? COLORS.cardBgDark : COLORS.cardBg
136
+ case "loading":
137
+ const loadingBackgroundColor = isDarkMode
138
+ ? COLORS.cardBgDark
139
+ : COLORS.cardBg;
92
140
 
93
141
  return (
94
- <View style={{
95
- width: '100%',
96
- padding: 10,
97
- borderRadius: 8,
98
- justifyContent: 'center',
99
- alignItems: 'center',
100
- backgroundColor: backgroundColor
101
- }}>
142
+ <View
143
+ style={{
144
+ width: "100%",
145
+ padding: 10,
146
+ borderRadius: 8,
147
+ justifyContent: "center",
148
+ alignItems: "center",
149
+ backgroundColor: loadingBackgroundColor,
150
+ }}
151
+ >
102
152
  <ActivityIndicator size={40} color={COLORS.primary} />
103
153
  </View>
104
154
  );
105
155
 
106
- case 'error':
156
+ case "error":
107
157
  return (
108
- <ErrorView state={uiState} onPress={() => { reconnect() }} />
109
- )
158
+ <ErrorView
159
+ state={uiState}
160
+ onPress={() => {
161
+ reconnect();
162
+ }}
163
+ />
164
+ );
110
165
 
111
- case 'reconnecting':
166
+ case "reconnecting":
112
167
  return (
113
- <ReconnectingView state={uiState} onPress={() => { reconnect() }} />
114
- )
168
+ <ReconnectingView
169
+ state={uiState}
170
+ onPress={() => {
171
+ reconnect();
172
+ }}
173
+ />
174
+ );
115
175
  default:
116
- return <View />
176
+ return <View />;
117
177
  }
118
178
  };
119
179
 
120
- export default LiveVoiceView;
180
+ export default LiveVoiceView;