@voltkit-rtc/react-native 0.0.0-stage → 0.1.1

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 (225) hide show
  1. package/CHANGELOG.md +121 -0
  2. package/LICENSE +21 -0
  3. package/README.md +1608 -2
  4. package/android/build.gradle +70 -0
  5. package/android/consumer-rules.pro +21 -0
  6. package/android/src/main/AndroidManifest.xml +25 -0
  7. package/android/src/main/java/com/voltkit/rtc/reactnative/AppVisibility.kt +67 -0
  8. package/android/src/main/java/com/voltkit/rtc/reactnative/AudioDevices.kt +67 -0
  9. package/android/src/main/java/com/voltkit/rtc/reactnative/AudioRouter.kt +487 -0
  10. package/android/src/main/java/com/voltkit/rtc/reactnative/CallServiceTypes.kt +120 -0
  11. package/android/src/main/java/com/voltkit/rtc/reactnative/NativeTimers.kt +106 -0
  12. package/android/src/main/java/com/voltkit/rtc/reactnative/NetworkWatch.kt +120 -0
  13. package/android/src/main/java/com/voltkit/rtc/reactnative/OutputChoice.kt +65 -0
  14. package/android/src/main/java/com/voltkit/rtc/reactnative/RtcConfig.kt +83 -0
  15. package/android/src/main/java/com/voltkit/rtc/reactnative/ScoLink.kt +61 -0
  16. package/android/src/main/java/com/voltkit/rtc/reactnative/VoltkitCallService.kt +287 -0
  17. package/android/src/main/java/com/voltkit/rtc/reactnative/VoltkitRtcInitProvider.kt +215 -0
  18. package/android/src/main/java/com/voltkit/rtc/reactnative/VoltkitRtcModule.kt +313 -0
  19. package/android/src/main/java/com/voltkit/rtc/reactnative/VoltkitRtcPackage.kt +30 -0
  20. package/android/src/main/res/drawable/voltkit_rtc_default_call_icon.xml +15 -0
  21. package/android/src/main/res/raw/voltkit_rtc_keep.xml +7 -0
  22. package/app.plugin.js +17 -0
  23. package/lib/commonjs/audio.js +215 -0
  24. package/lib/commonjs/audio.js.map +1 -0
  25. package/lib/commonjs/components.js +207 -0
  26. package/lib/commonjs/components.js.map +1 -0
  27. package/lib/commonjs/create-client.js +47 -0
  28. package/lib/commonjs/create-client.js.map +1 -0
  29. package/lib/commonjs/errors.js +99 -0
  30. package/lib/commonjs/errors.js.map +1 -0
  31. package/lib/commonjs/globals.js +61 -0
  32. package/lib/commonjs/globals.js.map +1 -0
  33. package/lib/commonjs/index.js +234 -0
  34. package/lib/commonjs/index.js.map +1 -0
  35. package/lib/commonjs/local-media.js +392 -0
  36. package/lib/commonjs/local-media.js.map +1 -0
  37. package/lib/commonjs/native-session.js +365 -0
  38. package/lib/commonjs/native-session.js.map +1 -0
  39. package/lib/commonjs/native.js +99 -0
  40. package/lib/commonjs/native.js.map +1 -0
  41. package/lib/commonjs/package.json +1 -0
  42. package/lib/commonjs/permissions.js +166 -0
  43. package/lib/commonjs/permissions.js.map +1 -0
  44. package/lib/commonjs/platform/android.js +126 -0
  45. package/lib/commonjs/platform/android.js.map +1 -0
  46. package/lib/commonjs/platform/common.js +138 -0
  47. package/lib/commonjs/platform/common.js.map +1 -0
  48. package/lib/commonjs/platform/devices.js +151 -0
  49. package/lib/commonjs/platform/devices.js.map +1 -0
  50. package/lib/commonjs/platform/index.js +35 -0
  51. package/lib/commonjs/platform/index.js.map +1 -0
  52. package/lib/commonjs/platform/ios.js +54 -0
  53. package/lib/commonjs/platform/ios.js.map +1 -0
  54. package/lib/commonjs/platform/streams.js +273 -0
  55. package/lib/commonjs/platform/streams.js.map +1 -0
  56. package/lib/commonjs/platform/timers.js +71 -0
  57. package/lib/commonjs/platform/timers.js.map +1 -0
  58. package/lib/commonjs/platform/visibility.js +60 -0
  59. package/lib/commonjs/platform/visibility.js.map +1 -0
  60. package/lib/commonjs/preflight.js +77 -0
  61. package/lib/commonjs/preflight.js.map +1 -0
  62. package/lib/commonjs/provider.js +75 -0
  63. package/lib/commonjs/provider.js.map +1 -0
  64. package/lib/commonjs/specs/NativeVoltkitRtc.js +29 -0
  65. package/lib/commonjs/specs/NativeVoltkitRtc.js.map +1 -0
  66. package/lib/module/audio.js +207 -0
  67. package/lib/module/audio.js.map +1 -0
  68. package/lib/module/components.js +200 -0
  69. package/lib/module/components.js.map +1 -0
  70. package/lib/module/create-client.js +42 -0
  71. package/lib/module/create-client.js.map +1 -0
  72. package/lib/module/errors.js +87 -0
  73. package/lib/module/errors.js.map +1 -0
  74. package/lib/module/globals.js +53 -0
  75. package/lib/module/globals.js.map +1 -0
  76. package/lib/module/index.js +33 -0
  77. package/lib/module/index.js.map +1 -0
  78. package/lib/module/local-media.js +387 -0
  79. package/lib/module/local-media.js.map +1 -0
  80. package/lib/module/native-session.js +360 -0
  81. package/lib/module/native-session.js.map +1 -0
  82. package/lib/module/native.js +87 -0
  83. package/lib/module/native.js.map +1 -0
  84. package/lib/module/package.json +1 -0
  85. package/lib/module/permissions.js +160 -0
  86. package/lib/module/permissions.js.map +1 -0
  87. package/lib/module/platform/android.js +122 -0
  88. package/lib/module/platform/android.js.map +1 -0
  89. package/lib/module/platform/common.js +128 -0
  90. package/lib/module/platform/common.js.map +1 -0
  91. package/lib/module/platform/devices.js +142 -0
  92. package/lib/module/platform/devices.js.map +1 -0
  93. package/lib/module/platform/index.js +24 -0
  94. package/lib/module/platform/index.js.map +1 -0
  95. package/lib/module/platform/ios.js +49 -0
  96. package/lib/module/platform/ios.js.map +1 -0
  97. package/lib/module/platform/streams.js +268 -0
  98. package/lib/module/platform/streams.js.map +1 -0
  99. package/lib/module/platform/timers.js +67 -0
  100. package/lib/module/platform/timers.js.map +1 -0
  101. package/lib/module/platform/visibility.js +54 -0
  102. package/lib/module/platform/visibility.js.map +1 -0
  103. package/lib/module/preflight.js +72 -0
  104. package/lib/module/preflight.js.map +1 -0
  105. package/lib/module/provider.js +70 -0
  106. package/lib/module/provider.js.map +1 -0
  107. package/lib/module/specs/NativeVoltkitRtc.js +37 -0
  108. package/lib/module/specs/NativeVoltkitRtc.js.map +1 -0
  109. package/lib/typescript/commonjs/audio.d.ts +58 -0
  110. package/lib/typescript/commonjs/audio.d.ts.map +1 -0
  111. package/lib/typescript/commonjs/components.d.ts +58 -0
  112. package/lib/typescript/commonjs/components.d.ts.map +1 -0
  113. package/lib/typescript/commonjs/create-client.d.ts +35 -0
  114. package/lib/typescript/commonjs/create-client.d.ts.map +1 -0
  115. package/lib/typescript/commonjs/errors.d.ts +34 -0
  116. package/lib/typescript/commonjs/errors.d.ts.map +1 -0
  117. package/lib/typescript/commonjs/globals.d.ts +16 -0
  118. package/lib/typescript/commonjs/globals.d.ts.map +1 -0
  119. package/lib/typescript/commonjs/index.d.ts +24 -0
  120. package/lib/typescript/commonjs/index.d.ts.map +1 -0
  121. package/lib/typescript/commonjs/local-media.d.ts +86 -0
  122. package/lib/typescript/commonjs/local-media.d.ts.map +1 -0
  123. package/lib/typescript/commonjs/native-session.d.ts +38 -0
  124. package/lib/typescript/commonjs/native-session.d.ts.map +1 -0
  125. package/lib/typescript/commonjs/native.d.ts +18 -0
  126. package/lib/typescript/commonjs/native.d.ts.map +1 -0
  127. package/lib/typescript/commonjs/package.json +1 -0
  128. package/lib/typescript/commonjs/permissions.d.ts +30 -0
  129. package/lib/typescript/commonjs/permissions.d.ts.map +1 -0
  130. package/lib/typescript/commonjs/platform/android.d.ts +4 -0
  131. package/lib/typescript/commonjs/platform/android.d.ts.map +1 -0
  132. package/lib/typescript/commonjs/platform/common.d.ts +101 -0
  133. package/lib/typescript/commonjs/platform/common.d.ts.map +1 -0
  134. package/lib/typescript/commonjs/platform/devices.d.ts +42 -0
  135. package/lib/typescript/commonjs/platform/devices.d.ts.map +1 -0
  136. package/lib/typescript/commonjs/platform/index.d.ts +6 -0
  137. package/lib/typescript/commonjs/platform/index.d.ts.map +1 -0
  138. package/lib/typescript/commonjs/platform/ios.d.ts +4 -0
  139. package/lib/typescript/commonjs/platform/ios.d.ts.map +1 -0
  140. package/lib/typescript/commonjs/platform/streams.d.ts +82 -0
  141. package/lib/typescript/commonjs/platform/streams.d.ts.map +1 -0
  142. package/lib/typescript/commonjs/platform/timers.d.ts +19 -0
  143. package/lib/typescript/commonjs/platform/timers.d.ts.map +1 -0
  144. package/lib/typescript/commonjs/platform/visibility.d.ts +11 -0
  145. package/lib/typescript/commonjs/platform/visibility.d.ts.map +1 -0
  146. package/lib/typescript/commonjs/preflight.d.ts +19 -0
  147. package/lib/typescript/commonjs/preflight.d.ts.map +1 -0
  148. package/lib/typescript/commonjs/provider.d.ts +35 -0
  149. package/lib/typescript/commonjs/provider.d.ts.map +1 -0
  150. package/lib/typescript/commonjs/specs/NativeVoltkitRtc.d.ts +157 -0
  151. package/lib/typescript/commonjs/specs/NativeVoltkitRtc.d.ts.map +1 -0
  152. package/lib/typescript/module/audio.d.ts +58 -0
  153. package/lib/typescript/module/audio.d.ts.map +1 -0
  154. package/lib/typescript/module/components.d.ts +58 -0
  155. package/lib/typescript/module/components.d.ts.map +1 -0
  156. package/lib/typescript/module/create-client.d.ts +35 -0
  157. package/lib/typescript/module/create-client.d.ts.map +1 -0
  158. package/lib/typescript/module/errors.d.ts +34 -0
  159. package/lib/typescript/module/errors.d.ts.map +1 -0
  160. package/lib/typescript/module/globals.d.ts +16 -0
  161. package/lib/typescript/module/globals.d.ts.map +1 -0
  162. package/lib/typescript/module/index.d.ts +24 -0
  163. package/lib/typescript/module/index.d.ts.map +1 -0
  164. package/lib/typescript/module/local-media.d.ts +86 -0
  165. package/lib/typescript/module/local-media.d.ts.map +1 -0
  166. package/lib/typescript/module/native-session.d.ts +38 -0
  167. package/lib/typescript/module/native-session.d.ts.map +1 -0
  168. package/lib/typescript/module/native.d.ts +18 -0
  169. package/lib/typescript/module/native.d.ts.map +1 -0
  170. package/lib/typescript/module/package.json +1 -0
  171. package/lib/typescript/module/permissions.d.ts +30 -0
  172. package/lib/typescript/module/permissions.d.ts.map +1 -0
  173. package/lib/typescript/module/platform/android.d.ts +4 -0
  174. package/lib/typescript/module/platform/android.d.ts.map +1 -0
  175. package/lib/typescript/module/platform/common.d.ts +101 -0
  176. package/lib/typescript/module/platform/common.d.ts.map +1 -0
  177. package/lib/typescript/module/platform/devices.d.ts +42 -0
  178. package/lib/typescript/module/platform/devices.d.ts.map +1 -0
  179. package/lib/typescript/module/platform/index.d.ts +6 -0
  180. package/lib/typescript/module/platform/index.d.ts.map +1 -0
  181. package/lib/typescript/module/platform/ios.d.ts +4 -0
  182. package/lib/typescript/module/platform/ios.d.ts.map +1 -0
  183. package/lib/typescript/module/platform/streams.d.ts +82 -0
  184. package/lib/typescript/module/platform/streams.d.ts.map +1 -0
  185. package/lib/typescript/module/platform/timers.d.ts +19 -0
  186. package/lib/typescript/module/platform/timers.d.ts.map +1 -0
  187. package/lib/typescript/module/platform/visibility.d.ts +11 -0
  188. package/lib/typescript/module/platform/visibility.d.ts.map +1 -0
  189. package/lib/typescript/module/preflight.d.ts +19 -0
  190. package/lib/typescript/module/preflight.d.ts.map +1 -0
  191. package/lib/typescript/module/provider.d.ts +35 -0
  192. package/lib/typescript/module/provider.d.ts.map +1 -0
  193. package/lib/typescript/module/specs/NativeVoltkitRtc.d.ts +157 -0
  194. package/lib/typescript/module/specs/NativeVoltkitRtc.d.ts.map +1 -0
  195. package/package.json +140 -4
  196. package/plugin/build/android.d.ts +36 -0
  197. package/plugin/build/android.js +265 -0
  198. package/plugin/build/index.d.ts +9 -0
  199. package/plugin/build/index.js +54 -0
  200. package/plugin/build/ios.d.ts +4 -0
  201. package/plugin/build/ios.js +43 -0
  202. package/plugin/build/options.d.ts +93 -0
  203. package/plugin/build/options.js +140 -0
  204. package/react-native.config.js +11 -0
  205. package/src/audio.ts +221 -0
  206. package/src/components.tsx +233 -0
  207. package/src/create-client.ts +53 -0
  208. package/src/errors.ts +81 -0
  209. package/src/globals.ts +54 -0
  210. package/src/index.ts +95 -0
  211. package/src/local-media.ts +420 -0
  212. package/src/native-session.tsx +384 -0
  213. package/src/native.ts +84 -0
  214. package/src/permissions.ts +173 -0
  215. package/src/platform/android.ts +128 -0
  216. package/src/platform/common.ts +157 -0
  217. package/src/platform/devices.ts +148 -0
  218. package/src/platform/index.ts +22 -0
  219. package/src/platform/ios.ts +48 -0
  220. package/src/platform/streams.ts +285 -0
  221. package/src/platform/timers.ts +72 -0
  222. package/src/platform/visibility.ts +59 -0
  223. package/src/preflight.ts +60 -0
  224. package/src/provider.tsx +88 -0
  225. package/src/specs/NativeVoltkitRtc.ts +180 -0
@@ -0,0 +1,360 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * What a connected call needs from the device on Android, kept by the provider for its client:
5
+ *
6
+ * - The call audio (audio.ts): held from the join to the close, so the audio mode, focus and routing are a call's; two
7
+ * clients (a PK battle) hold it together and the last out restores the device.
8
+ * - The call service: a foreground service that keeps the call's network, microphone and timers alive while the app is
9
+ * in the background or the screen is off. Without it Android cuts the app's sockets about 6 s after it leaves the
10
+ * foreground or the screen goes off (Phase 0 finding 3). It runs while any call is live, for every client together
11
+ * (one notification), when the app's manifest declares it (the Expo plugin's callService, default on). Android lets
12
+ * it start, and take new foreground service types (the camera, a screen share), only while the app is visible: it
13
+ * starts on the join and is brought up to date whenever the app comes back to the front. Its notification's Leave
14
+ * action, and the app being swiped away from Recents, close every client it runs for (close code 1000, `left`).
15
+ * Failures reach the provider's onError as `media-unavailable` with `{ feature: 'callService' }`.
16
+ */
17
+ import { useEffect, useMemo, useRef, useSyncExternalStore } from 'react';
18
+ import { useVoltkitClient } from '@voltkit-rtc/react';
19
+ import { listen, nativeConstants, nativeModule } from "./native.js";
20
+ import { callServiceFailed, describeError, logError } from "./errors.js";
21
+ import { audioHoldOf, speakerPreference } from "./audio.js";
22
+ import { localSessionOf } from "./local-media.js";
23
+ import { nativeVisibility } from "./platform/visibility.js";
24
+ import { localStream } from "./platform/common.js";
25
+
26
+ /** The call service's notification. */
27
+
28
+ /** How the provider manages the call audio. */
29
+
30
+ // ----------------------------------------------------------------------------------------- the call service, shared
31
+
32
+ const NOT_DECLARED = Object.freeze({
33
+ declared: false,
34
+ running: false,
35
+ types: Object.freeze([])
36
+ });
37
+ class CallServices {
38
+ /**
39
+ * What each call wants, read afresh at every decision: a call's state is its client's, which emits no event for some
40
+ * changes. With how to tell the call when its state cannot be read at all.
41
+ */
42
+ wants = new Map();
43
+ running = false;
44
+ /** The call to the native module under way: a `failed` event during a start or update is its rejection's twin. */
45
+ inFlight = null;
46
+ again = false;
47
+ /** The options the service runs with, as sent. */
48
+ applied = null;
49
+ /** Options a start failed for: not tried again until they change or the app comes back to the front. */
50
+ failed = null;
51
+ watching = null;
52
+ state = null;
53
+ listeners = new Set();
54
+ set(key, want, report = () => undefined) {
55
+ if (want) this.wants.set(key, {
56
+ want,
57
+ report
58
+ });else this.wants.delete(key);
59
+ this.reconcile();
60
+ }
61
+
62
+ /** Something a call publishes may have changed: decide again. */
63
+ changed() {
64
+ this.reconcile();
65
+ }
66
+ subscribe = listener => {
67
+ this.listeners.add(listener);
68
+ return () => {
69
+ this.listeners.delete(listener);
70
+ };
71
+ };
72
+ snapshot = () => {
73
+ if (this.state) return this.state;
74
+ const module = nativeModule();
75
+ if (!module || !nativeConstants()?.callServiceDeclared) return NOT_DECLARED;
76
+ let status = {
77
+ declared: true,
78
+ running: false,
79
+ types: []
80
+ };
81
+ try {
82
+ status = module.getCallServiceStatus();
83
+ } catch (err) {
84
+ logError('could not read the call service\'s status', err);
85
+ }
86
+ this.state = {
87
+ declared: status.declared,
88
+ running: status.running,
89
+ types: [...status.types]
90
+ };
91
+ return this.state;
92
+ };
93
+ publish(status) {
94
+ const now = this.snapshot();
95
+ const next = {
96
+ ...now,
97
+ ...status
98
+ };
99
+ if (next.running === now.running && next.declared === now.declared && next.types.join() === now.types.join()) return;
100
+ this.state = next;
101
+ for (const listener of [...this.listeners]) listener();
102
+ }
103
+ live() {
104
+ const live = [];
105
+ for (const [key, {
106
+ want,
107
+ report
108
+ }] of [...this.wants]) {
109
+ let w;
110
+ try {
111
+ w = want();
112
+ } catch (err) {
113
+ // A client whose state cannot be read (a wrapper that throws on a read): this call is left out of the service
114
+ // for good, said once, and never keeps the other calls from theirs (the verifier's F3 on 0.1.1).
115
+ this.wants.delete(key);
116
+ logError('a call is left out of the call service: its client\'s state could not be read', err);
117
+ try {
118
+ report(callServiceFailed(`this call is left out, its client's state could not be read: ${describeError(err)}`));
119
+ } catch (reportErr) {
120
+ logError('onError threw', reportErr);
121
+ }
122
+ continue;
123
+ }
124
+ if (w.live) live.push(w);
125
+ }
126
+ return live;
127
+ }
128
+ reconcile() {
129
+ const module = nativeModule();
130
+ if (!module || !nativeConstants()?.callServiceDeclared) return;
131
+ const live = this.live();
132
+ this.watch(module, live.length > 0 || this.running);
133
+ if (this.inFlight) {
134
+ this.again = true;
135
+ return;
136
+ }
137
+ if (live.length === 0) {
138
+ this.failed = null;
139
+ if (this.running || this.applied !== null) this.run(module, 'stop', null);
140
+ return;
141
+ }
142
+ const options = merged(live);
143
+ const key = JSON.stringify(options);
144
+ if (this.running && key === this.applied || key === this.failed) return;
145
+ // Android lets a foreground service start, or widen its types, only while the app is visible.
146
+ if (!safeVisible(module)) return;
147
+ this.run(module, this.running ? 'update' : 'start', options);
148
+ }
149
+ run(module, what, options) {
150
+ this.inFlight = what;
151
+ const key = options ? JSON.stringify(options) : null;
152
+ const call = what === 'stop' ? module.stopCallService() : what === 'start' ? module.startCallService(options) : module.updateCallService(options);
153
+ call.then(status => {
154
+ this.running = status.running;
155
+ this.applied = status.running ? key : null;
156
+ if (status.running) this.failed = null;
157
+ this.publish({
158
+ declared: status.declared,
159
+ running: status.running,
160
+ types: [...status.types]
161
+ });
162
+ }, err => {
163
+ if (what === 'stop') {
164
+ logError('could not stop the call service', err);
165
+ return;
166
+ }
167
+ this.failed = key;
168
+ const error = callServiceFailed(describeError(err));
169
+ for (const want of this.live()) want.report(error);
170
+ }).finally(() => {
171
+ this.inFlight = null;
172
+ if (this.again) {
173
+ this.again = false;
174
+ this.reconcile();
175
+ return;
176
+ }
177
+ // Nothing left to keep running: stop listening until the next call.
178
+ if (!this.running && this.live().length === 0) this.watch(module, false);
179
+ });
180
+ }
181
+
182
+ /** Visibility and the service's own events, while a call is live or the service runs. */
183
+ watch(module, on) {
184
+ if (on === (this.watching !== null)) return;
185
+ if (!on) {
186
+ this.watching?.();
187
+ this.watching = null;
188
+ return;
189
+ }
190
+ const visibility = nativeVisibility(module);
191
+ const stops = [visibility.subscribe(visible => {
192
+ if (!visible) return;
193
+ // Back in front: try again what failed, and bring the service up to date.
194
+ this.failed = null;
195
+ this.reconcile();
196
+ }), listen(module.onCallServiceEvent, 'onCallServiceEvent', event => this.onEvent(event.type, event.types, event.message))];
197
+ this.watching = () => {
198
+ for (const stop of stops) stop();
199
+ };
200
+ }
201
+ onEvent(type, types, message) {
202
+ switch (type) {
203
+ case 'started':
204
+ case 'updated':
205
+ this.running = true;
206
+ this.publish({
207
+ running: true,
208
+ types: [...types]
209
+ });
210
+ return;
211
+ case 'stopped':
212
+ this.running = false;
213
+ this.applied = null;
214
+ // Stopped from outside while a call is live: started again when the app next comes to the front, not now.
215
+ if (this.live().length > 0) this.failed = JSON.stringify(merged(this.live()));
216
+ this.publish({
217
+ running: false,
218
+ types: []
219
+ });
220
+ this.reconcile();
221
+ return;
222
+ case 'leave':
223
+ case 'taskRemoved':
224
+ for (const want of this.live()) want.leave();
225
+ return;
226
+ case 'failed':
227
+ {
228
+ // VoltkitCallService.runWith tells `failed` and then rejects the start or update: the rejection reports it (RN010-2).
229
+ if (this.inFlight === 'start' || this.inFlight === 'update') return;
230
+ const error = callServiceFailed(message || 'Android refused it');
231
+ for (const want of this.live()) want.report(error);
232
+ return;
233
+ }
234
+ default:
235
+ }
236
+ }
237
+ }
238
+ function safeVisible(module) {
239
+ try {
240
+ return module.isAppVisible();
241
+ } catch {
242
+ return true;
243
+ }
244
+ }
245
+
246
+ /** What the service runs with for these calls together. */
247
+ function merged(live) {
248
+ const text = [...live].reverse();
249
+ const pick = field => text.find(w => w.text[field])?.text[field] ?? '';
250
+ return {
251
+ title: pick('title'),
252
+ text: pick('text'),
253
+ leaveLabel: pick('leaveLabel'),
254
+ // The camera type only for a call that keeps its camera on in the background.
255
+ pauseCamera: !live.some(w => w.cameraPublished && !w.pauseCamera),
256
+ micPublished: live.some(w => w.micPublished),
257
+ cameraPublished: live.some(w => w.cameraPublished),
258
+ sharing: live.some(w => w.sharing)
259
+ };
260
+ }
261
+ const callServices = new CallServices();
262
+
263
+ /** The call service: whether the app declares it, whether it runs and with which types. */
264
+ export function useCallService() {
265
+ return useSyncExternalStore(callServices.subscribe, callServices.snapshot, callServices.snapshot);
266
+ }
267
+
268
+ // ---------------------------------------------------------------------------------------------- the provider's part
269
+
270
+ /** Rendered by the provider inside @voltkit-rtc/react's provider: keeps the call audio and the call service for its client. */
271
+ export function NativeSession({
272
+ audio,
273
+ callService,
274
+ pauseCamera,
275
+ onError
276
+ }) {
277
+ const client = useVoltkitClient();
278
+ const manage = audio !== false && audio?.manage !== false;
279
+ const speakerphone = audio === false ? undefined : audio?.speakerphone;
280
+ const wantsService = callService !== false;
281
+ const text = useMemo(() => typeof callService === 'object' && callService !== null ? callService : {}, [callService]);
282
+ const latest = useRef({
283
+ speakerphone,
284
+ text,
285
+ pauseCamera
286
+ });
287
+ useEffect(() => {
288
+ latest.current = {
289
+ speakerphone,
290
+ text,
291
+ pauseCamera
292
+ };
293
+ });
294
+
295
+ // What useLocalMedia shows (the screen being shared) is recorded for as long as the provider has the client.
296
+ useEffect(() => client ? localSessionOf(client).hold() : undefined, [client]);
297
+ useEffect(() => {
298
+ if (!client || !manage || !nativeModule()) return;
299
+ const hold = audioHoldOf(client, error => onError.current?.(error));
300
+ hold.retain();
301
+ const sync = () => {
302
+ const state = client.connectionState;
303
+ if (state === 'connected' || state === 'reconnecting') hold.acquire(speakerPreference(latest.current.speakerphone));else if (state === 'closed') hold.release();
304
+ };
305
+ sync();
306
+ const off = client.on('connectionStateChanged', sync);
307
+ return () => {
308
+ off();
309
+ hold.unretain();
310
+ };
311
+ }, [client, manage, onError]);
312
+ useEffect(() => {
313
+ if (!client || !wantsService || !nativeModule()) return;
314
+ const key = {};
315
+ const report = error => onError.current?.(error);
316
+ callServices.set(key, () => wantOf(client, latest.current, report), report);
317
+ const update = () => callServices.changed();
318
+ // publish() and a camera switch emit no event of their own: useLocalMedia's calls say so through the local session.
319
+ const offs = [...['connectionStateChanged', 'localMediaChanged', 'localStreamChanged', 'screenShareStarted', 'screenShareEnded'].map(event => client.on(event, update)), localSessionOf(client).subscribe(update)];
320
+ return () => {
321
+ for (const off of offs) off();
322
+ callServices.set(key, null);
323
+ };
324
+ }, [client, wantsService, onError]);
325
+ return null;
326
+ }
327
+ function wantOf(client, latest, report) {
328
+ const state = client.connectionState;
329
+ const local = localStream(client);
330
+ return {
331
+ live: state === 'connected' || state === 'reconnecting',
332
+ micPublished: (local?.getAudioTracks().length ?? 0) > 0,
333
+ cameraPublished: (local?.getVideoTracks().length ?? 0) > 0,
334
+ sharing: localSessionOf(client).screen !== null,
335
+ pauseCamera: pausesCameraInBackground(client) ?? latest.pauseCamera,
336
+ text: latest.text,
337
+ leave: () => client.close(),
338
+ report
339
+ };
340
+ }
341
+
342
+ /**
343
+ * Whether the client switches its camera off in the background, from its own options: the provider's `background` only
344
+ * describes a client the provider made, and an app-made one (`createClient`, the `client` prop) keeps its camera on with
345
+ * `pauseCamera: false` while the service was asked for no camera type, so Android cut the camera (RN010-1). The client
346
+ * pauses only with `pauseCameraInBackground === true` (left out, the camera runs on). Null when the options cannot be
347
+ * read (missing, not an object, or a read that throws: a wrapped or stubbed client): the provider's setting stands in.
348
+ */
349
+ function pausesCameraInBackground(client) {
350
+ let options;
351
+ try {
352
+ options = client.options;
353
+ } catch {
354
+ // A wrapper that forbids the read (a logging or sealing Proxy): not an error, the provider's setting stands in.
355
+ return null;
356
+ }
357
+ if (!options || typeof options !== 'object') return null;
358
+ return options.pauseCameraInBackground === true;
359
+ }
360
+ //# sourceMappingURL=native-session.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useEffect","useMemo","useRef","useSyncExternalStore","useVoltkitClient","listen","nativeConstants","nativeModule","callServiceFailed","describeError","logError","audioHoldOf","speakerPreference","localSessionOf","nativeVisibility","localStream","NOT_DECLARED","Object","freeze","declared","running","types","CallServices","wants","Map","inFlight","again","applied","failed","watching","state","listeners","Set","set","key","want","report","undefined","delete","reconcile","changed","subscribe","listener","add","snapshot","module","callServiceDeclared","status","getCallServiceStatus","err","publish","now","next","join","live","w","reportErr","push","watch","length","run","options","merged","JSON","stringify","safeVisible","what","call","stopCallService","startCallService","updateCallService","then","error","finally","on","visibility","stops","visible","onCallServiceEvent","event","onEvent","type","message","stop","leave","isAppVisible","text","reverse","pick","field","find","title","leaveLabel","pauseCamera","some","cameraPublished","micPublished","sharing","callServices","useCallService","NativeSession","audio","callService","onError","client","manage","speakerphone","wantsService","latest","current","hold","retain","sync","connectionState","acquire","release","off","unretain","wantOf","update","offs","map","local","getAudioTracks","getVideoTracks","screen","pausesCameraInBackground","close","pauseCameraInBackground"],"sourceRoot":"../../src","sources":["native-session.tsx"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,oBAAoB,QAAQ,OAAO;AAExE,SAASC,gBAAgB,QAAQ,oBAAoB;AAErD,SAASC,MAAM,EAAEC,eAAe,EAAEC,YAAY,QAAQ,aAAU;AAChE,SAASC,iBAAiB,EAAEC,aAAa,EAAEC,QAAQ,QAAQ,aAAU;AACrE,SAASC,WAAW,EAAEC,iBAAiB,QAAQ,YAAS;AACxD,SAASC,cAAc,QAAQ,kBAAe;AAC9C,SAASC,gBAAgB,QAAQ,0BAAuB;AACxD,SAASC,WAAW,QAAQ,sBAAmB;;AAE/C;;AAUA;;AAQA;;AAuBA,MAAMC,YAA8B,GAAGC,MAAM,CAACC,MAAM,CAAC;EAAEC,QAAQ,EAAE,KAAK;EAAEC,OAAO,EAAE,KAAK;EAAEC,KAAK,EAAEJ,MAAM,CAACC,MAAM,CAAC,EAAE;AAAyB,CAAC,CAAC;AAE1I,MAAMI,YAAY,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I;EACb;EACA,IAAI,CAACA,OAAO,IAAI,OAAOA,OAAO,KAAK,QAAQ,EAAE,OAAO,IAAI;EACxD,OAAQA,OAAO,CAAmBmE,uBAAuB,KAAK,IAAI;AACpE","ignoreList":[]}
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * This package's native module (src/specs/NativeVoltkitRtc.ts), read only through here: it is null on iOS (JavaScript
5
+ * only in 0.1.0), in Expo Go and wherever the app was not rebuilt after installing the package. Everything that can do
6
+ * without it does (JavaScript timers, AppState); what cannot raises `media-unavailable` (errors.ts).
7
+ */
8
+ import { Platform } from 'react-native';
9
+ import NativeVoltkitRtc from "./specs/NativeVoltkitRtc.js";
10
+ import { iosUnsupported, logError, nativeMissing } from "./errors.js";
11
+ /** The version of this package: what getDiagnostics() reports, and what the native side was built from. */
12
+ export const SDK_VERSION = '0.1.1';
13
+
14
+ /** The native module, or null where there is none (iOS, Expo Go, an app not rebuilt). */
15
+ export function nativeModule() {
16
+ if (Platform.OS !== 'android') return null;
17
+ return NativeVoltkitRtc ?? null;
18
+ }
19
+ let constants = null;
20
+ let staleWarned = false;
21
+
22
+ /** The module's constants, read once: the audio mode, screen sharing, the call service as the manifest declares them. */
23
+ export function nativeConstants() {
24
+ const module = nativeModule();
25
+ if (!module) return null;
26
+ if (constants?.module === module) return constants.value;
27
+ let value;
28
+ try {
29
+ value = module.getConstants();
30
+ } catch (err) {
31
+ logError('could not read the native module\'s constants', err);
32
+ return null;
33
+ }
34
+ constants = {
35
+ module,
36
+ value
37
+ };
38
+ if (!staleWarned && value.nativeVersion && value.nativeVersion !== SDK_VERSION) {
39
+ staleWarned = true;
40
+ // eslint-disable-next-line no-console
41
+ console.warn(`[voltkit-rtc] the app's native code is @voltkit-rtc/react-native ${value.nativeVersion} but its JavaScript is ${SDK_VERSION}: rebuild the app`);
42
+ }
43
+ return value;
44
+ }
45
+
46
+ /** The native module for `feature`, or the error that says why there is none. */
47
+ export function requireNative(feature) {
48
+ if (Platform.OS === 'ios') throw iosUnsupported(feature);
49
+ const module = nativeModule();
50
+ if (!module) throw nativeMissing(feature);
51
+ return module;
52
+ }
53
+
54
+ /** Subscribe to one of the module's events; a listener that throws is logged and the others still run. */
55
+ export function listen(emitter, name, listener) {
56
+ if (typeof emitter !== 'function') return () => undefined;
57
+ const subscription = emitter(value => {
58
+ try {
59
+ listener(value);
60
+ } catch (err) {
61
+ logError(`listener for ${name} threw`, err);
62
+ }
63
+ });
64
+ return () => subscription.remove();
65
+ }
66
+ const AUDIO_TYPES = ['speaker', 'earpiece', 'wiredHeadset', 'bluetooth', 'usb', 'builtinMic', 'other'];
67
+ const KINDS = ['audioinput', 'audiooutput', 'videoinput'];
68
+
69
+ /** A native audio device as the client's MediaDevice. */
70
+ export function toMediaDevice(device) {
71
+ const type = AUDIO_TYPES.includes(device.type) ? device.type : 'other';
72
+ const kind = KINDS.includes(device.kind) ? device.kind : 'audiooutput';
73
+ return {
74
+ deviceId: device.deviceId,
75
+ groupId: device.groupId ?? '',
76
+ kind,
77
+ label: device.label,
78
+ type
79
+ };
80
+ }
81
+
82
+ /** For tests: forget the cached constants. */
83
+ export function resetNativeForTests() {
84
+ constants = null;
85
+ staleWarned = false;
86
+ }
87
+ //# sourceMappingURL=native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Platform","NativeVoltkitRtc","iosUnsupported","logError","nativeMissing","SDK_VERSION","nativeModule","OS","constants","staleWarned","nativeConstants","module","value","getConstants","err","nativeVersion","console","warn","requireNative","feature","listen","emitter","name","listener","undefined","subscription","remove","AUDIO_TYPES","KINDS","toMediaDevice","device","type","includes","kind","deviceId","groupId","label","resetNativeForTests"],"sourceRoot":"../../src","sources":["native.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA,SAASA,QAAQ,QAAQ,cAAc;AAEvC,OAAOC,gBAAgB,MAAuD,6BAA0B;AACxG,SAASC,cAAc,EAAEC,QAAQ,EAAEC,aAAa,QAAQ,aAAU;AAGlE;AACA,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4
+ * Camera, microphone and notification permissions.
5
+ *
6
+ * Android: PermissionsAndroid. `blocked` is Android's "never ask again" (the user refused twice, or chose "Don't ask
7
+ * again"): only the app's settings can grant it now. The notification permission (Android 13+, POST_NOTIFICATIONS,
8
+ * for the call service's notification) is asked only when asked for; below Android 13 there is none to ask.
9
+ *
10
+ * iOS (preview): react-native-webrtc's permissions module. iOS asks once: a refusal is `blocked` from then on.
11
+ *
12
+ * useLocalMedia().publish() asks for what it needs before any device opens, so a refusal is a `media-unavailable`
13
+ * error with `{ permission, status }` and the camera light never comes on. The SDK's own captures afterwards (a
14
+ * reconnect, a switch) only check, never ask: a dialog must not open in the background.
15
+ */
16
+ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
17
+ import { AppState, PermissionsAndroid, Platform } from 'react-native';
18
+ import { loadWebRTC } from "./globals.js";
19
+ import { logError } from "./errors.js";
20
+
21
+ /** What can be asked for. */
22
+
23
+ /** `granted`; `denied` (not granted yet: asking may still show the dialog); `blocked` (only the settings can grant it). */
24
+
25
+ const ANDROID = {
26
+ camera: 'android.permission.CAMERA',
27
+ microphone: 'android.permission.RECORD_AUDIO',
28
+ notifications: 'android.permission.POST_NOTIFICATIONS'
29
+ };
30
+ const unique = kinds => [...new Set(kinds)];
31
+
32
+ /** Android 13 and later have a notification permission; below, notifications need none. */
33
+ const notificationsNeedAsking = () => Platform.OS === 'android' && Number(Platform.Version) >= 33;
34
+
35
+ /**
36
+ * Ask for these permissions, showing the system's dialogs for those not granted yet. Resolves with each one's status;
37
+ * never rejects.
38
+ */
39
+ export async function requestMediaPermissions(kinds) {
40
+ const wanted = unique(kinds);
41
+ const out = {};
42
+ if (wanted.length === 0) return out;
43
+ if (Platform.OS === 'android') {
44
+ const ask = wanted.filter(k => k !== 'notifications' || notificationsNeedAsking());
45
+ for (const kind of wanted) if (!ask.includes(kind)) out[kind] = 'granted';
46
+ if (ask.length === 0) return out;
47
+ let results = {};
48
+ try {
49
+ results = await PermissionsAndroid.requestMultiple(ask.map(k => ANDROID[k]));
50
+ } catch (err) {
51
+ logError('could not ask for permissions', err);
52
+ }
53
+ for (const kind of ask) out[kind] = androidStatus(results[ANDROID[kind]]);
54
+ return out;
55
+ }
56
+ for (const kind of wanted) out[kind] = await requestIos(kind);
57
+ return out;
58
+ }
59
+
60
+ /** Each permission's status now, without asking. Never rejects. */
61
+ export async function checkMediaPermissions(kinds) {
62
+ const wanted = unique(kinds);
63
+ const out = {};
64
+ for (const kind of wanted) {
65
+ if (Platform.OS === 'android') {
66
+ if (kind === 'notifications' && !notificationsNeedAsking()) {
67
+ out[kind] = 'granted';
68
+ continue;
69
+ }
70
+ try {
71
+ out[kind] = (await PermissionsAndroid.check(ANDROID[kind])) ? 'granted' : 'denied';
72
+ } catch (err) {
73
+ logError('could not check a permission', err);
74
+ out[kind] = 'denied';
75
+ }
76
+ } else {
77
+ out[kind] = await queryIos(kind);
78
+ }
79
+ }
80
+ return out;
81
+ }
82
+ function androidStatus(result) {
83
+ if (result === 'granted') return 'granted';
84
+ if (result === 'never_ask_again') return 'blocked';
85
+ return 'denied';
86
+ }
87
+ async function queryIos(kind) {
88
+ // The SDK shows no notification of its own on iOS: nothing to ask.
89
+ if (kind === 'notifications') return 'granted';
90
+ const webrtc = loadWebRTC();
91
+ if (!webrtc) return 'denied';
92
+ try {
93
+ const result = await webrtc.permissions.query({
94
+ name: kind
95
+ });
96
+ if (result === 'granted') return 'granted';
97
+ return result === 'denied' ? 'blocked' : 'denied';
98
+ } catch (err) {
99
+ logError('could not check a permission', err);
100
+ return 'denied';
101
+ }
102
+ }
103
+ async function requestIos(kind) {
104
+ const now = await queryIos(kind);
105
+ if (now !== 'denied') return now;
106
+ const webrtc = loadWebRTC();
107
+ if (!webrtc) return 'denied';
108
+ try {
109
+ return (await webrtc.permissions.request({
110
+ name: kind
111
+ })) ? 'granted' : 'blocked';
112
+ } catch (err) {
113
+ logError('could not ask for a permission', err);
114
+ return 'denied';
115
+ }
116
+ }
117
+ /**
118
+ * The status of these permissions, checked on mount and whenever the app returns to the front (the user may have
119
+ * changed them in the settings), with `request()` to ask for them.
120
+ */
121
+ export function usePermissions(kinds) {
122
+ const key = unique(kinds).sort().join(',');
123
+ const wanted = useMemo(() => key ? key.split(',') : [], [key]);
124
+ const [statuses, setStatuses] = useState(null);
125
+ const live = useRef(true);
126
+ const refresh = useCallback(async () => {
127
+ const next = await checkMediaPermissions(wanted);
128
+ if (live.current) setStatuses(previous => same(previous, next) ? previous : next);
129
+ return next;
130
+ }, [wanted]);
131
+ const request = useCallback(async () => {
132
+ const next = await requestMediaPermissions(wanted);
133
+ if (live.current) setStatuses(previous => same(previous, next) ? previous : next);
134
+ return next;
135
+ }, [wanted]);
136
+ useEffect(() => {
137
+ live.current = true;
138
+ void refresh();
139
+ const subscription = AppState.addEventListener('change', state => {
140
+ if (state === 'active') void refresh();
141
+ });
142
+ return () => {
143
+ live.current = false;
144
+ subscription?.remove();
145
+ };
146
+ }, [refresh]);
147
+ const granted = statuses !== null && wanted.every(k => statuses[k] === 'granted');
148
+ return useMemo(() => ({
149
+ statuses,
150
+ granted,
151
+ request,
152
+ refresh
153
+ }), [statuses, granted, request, refresh]);
154
+ }
155
+ function same(a, b) {
156
+ if (!a) return false;
157
+ const keys = Object.keys(b);
158
+ return keys.length === Object.keys(a).length && keys.every(k => a[k] === b[k]);
159
+ }
160
+ //# sourceMappingURL=permissions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useCallback","useEffect","useMemo","useRef","useState","AppState","PermissionsAndroid","Platform","loadWebRTC","logError","ANDROID","camera","microphone","notifications","unique","kinds","Set","notificationsNeedAsking","OS","Number","Version","requestMediaPermissions","wanted","out","length","ask","filter","k","kind","includes","results","requestMultiple","map","err","androidStatus","requestIos","checkMediaPermissions","check","queryIos","result","webrtc","permissions","query","name","now","request","usePermissions","key","sort","join","split","statuses","setStatuses","live","refresh","next","current","previous","same","subscription","addEventListener","state","remove","granted","every","a","b","keys","Object"],"sourceRoot":"../../src","sources":["perm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