@robono/calling-react-native 0.2.2 → 0.4.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.
- package/CHANGELOG.md +21 -2
- package/README.md +97 -4
- package/RobonoCallingRuntime.podspec +1 -1
- package/SBOM.spdx.json +6982 -190
- package/android/build.gradle +1 -1
- package/android/consumer-rules.pro +5 -0
- package/android/src/main/java/com/robono/calling/CallingRuntime.java +29 -3
- package/android/src/main/java/com/robono/calling/CallingWarnings.java +59 -0
- package/app.plugin.cjs +4 -2
- package/assets/countdown/1.m4a +0 -0
- package/assets/countdown/10.m4a +0 -0
- package/assets/countdown/100.m4a +0 -0
- package/assets/countdown/101.m4a +0 -0
- package/assets/countdown/102.m4a +0 -0
- package/assets/countdown/103.m4a +0 -0
- package/assets/countdown/104.m4a +0 -0
- package/assets/countdown/105.m4a +0 -0
- package/assets/countdown/106.m4a +0 -0
- package/assets/countdown/107.m4a +0 -0
- package/assets/countdown/108.m4a +0 -0
- package/assets/countdown/109.m4a +0 -0
- package/assets/countdown/11.m4a +0 -0
- package/assets/countdown/110.m4a +0 -0
- package/assets/countdown/111.m4a +0 -0
- package/assets/countdown/112.m4a +0 -0
- package/assets/countdown/113.m4a +0 -0
- package/assets/countdown/114.m4a +0 -0
- package/assets/countdown/115.m4a +0 -0
- package/assets/countdown/116.m4a +0 -0
- package/assets/countdown/117.m4a +0 -0
- package/assets/countdown/118.m4a +0 -0
- package/assets/countdown/119.m4a +0 -0
- package/assets/countdown/12.m4a +0 -0
- package/assets/countdown/120.m4a +0 -0
- package/assets/countdown/121.m4a +0 -0
- package/assets/countdown/122.m4a +0 -0
- package/assets/countdown/123.m4a +0 -0
- package/assets/countdown/124.m4a +0 -0
- package/assets/countdown/125.m4a +0 -0
- package/assets/countdown/126.m4a +0 -0
- package/assets/countdown/127.m4a +0 -0
- package/assets/countdown/128.m4a +0 -0
- package/assets/countdown/129.m4a +0 -0
- package/assets/countdown/13.m4a +0 -0
- package/assets/countdown/130.m4a +0 -0
- package/assets/countdown/131.m4a +0 -0
- package/assets/countdown/132.m4a +0 -0
- package/assets/countdown/133.m4a +0 -0
- package/assets/countdown/134.m4a +0 -0
- package/assets/countdown/135.m4a +0 -0
- package/assets/countdown/136.m4a +0 -0
- package/assets/countdown/137.m4a +0 -0
- package/assets/countdown/138.m4a +0 -0
- package/assets/countdown/139.m4a +0 -0
- package/assets/countdown/14.m4a +0 -0
- package/assets/countdown/140.m4a +0 -0
- package/assets/countdown/141.m4a +0 -0
- package/assets/countdown/142.m4a +0 -0
- package/assets/countdown/143.m4a +0 -0
- package/assets/countdown/144.m4a +0 -0
- package/assets/countdown/145.m4a +0 -0
- package/assets/countdown/146.m4a +0 -0
- package/assets/countdown/147.m4a +0 -0
- package/assets/countdown/148.m4a +0 -0
- package/assets/countdown/149.m4a +0 -0
- package/assets/countdown/15.m4a +0 -0
- package/assets/countdown/150.m4a +0 -0
- package/assets/countdown/151.m4a +0 -0
- package/assets/countdown/152.m4a +0 -0
- package/assets/countdown/153.m4a +0 -0
- package/assets/countdown/154.m4a +0 -0
- package/assets/countdown/155.m4a +0 -0
- package/assets/countdown/156.m4a +0 -0
- package/assets/countdown/157.m4a +0 -0
- package/assets/countdown/158.m4a +0 -0
- package/assets/countdown/159.m4a +0 -0
- package/assets/countdown/16.m4a +0 -0
- package/assets/countdown/160.m4a +0 -0
- package/assets/countdown/161.m4a +0 -0
- package/assets/countdown/162.m4a +0 -0
- package/assets/countdown/163.m4a +0 -0
- package/assets/countdown/164.m4a +0 -0
- package/assets/countdown/165.m4a +0 -0
- package/assets/countdown/166.m4a +0 -0
- package/assets/countdown/167.m4a +0 -0
- package/assets/countdown/168.m4a +0 -0
- package/assets/countdown/169.m4a +0 -0
- package/assets/countdown/17.m4a +0 -0
- package/assets/countdown/170.m4a +0 -0
- package/assets/countdown/171.m4a +0 -0
- package/assets/countdown/172.m4a +0 -0
- package/assets/countdown/173.m4a +0 -0
- package/assets/countdown/174.m4a +0 -0
- package/assets/countdown/175.m4a +0 -0
- package/assets/countdown/176.m4a +0 -0
- package/assets/countdown/177.m4a +0 -0
- package/assets/countdown/178.m4a +0 -0
- package/assets/countdown/179.m4a +0 -0
- package/assets/countdown/18.m4a +0 -0
- package/assets/countdown/180.m4a +0 -0
- package/assets/countdown/181.m4a +0 -0
- package/assets/countdown/182.m4a +0 -0
- package/assets/countdown/183.m4a +0 -0
- package/assets/countdown/184.m4a +0 -0
- package/assets/countdown/185.m4a +0 -0
- package/assets/countdown/186.m4a +0 -0
- package/assets/countdown/187.m4a +0 -0
- package/assets/countdown/188.m4a +0 -0
- package/assets/countdown/189.m4a +0 -0
- package/assets/countdown/19.m4a +0 -0
- package/assets/countdown/190.m4a +0 -0
- package/assets/countdown/191.m4a +0 -0
- package/assets/countdown/192.m4a +0 -0
- package/assets/countdown/193.m4a +0 -0
- package/assets/countdown/194.m4a +0 -0
- package/assets/countdown/195.m4a +0 -0
- package/assets/countdown/196.m4a +0 -0
- package/assets/countdown/197.m4a +0 -0
- package/assets/countdown/198.m4a +0 -0
- package/assets/countdown/199.m4a +0 -0
- package/assets/countdown/2.m4a +0 -0
- package/assets/countdown/20.m4a +0 -0
- package/assets/countdown/200.m4a +0 -0
- package/assets/countdown/201.m4a +0 -0
- package/assets/countdown/202.m4a +0 -0
- package/assets/countdown/203.m4a +0 -0
- package/assets/countdown/204.m4a +0 -0
- package/assets/countdown/205.m4a +0 -0
- package/assets/countdown/206.m4a +0 -0
- package/assets/countdown/207.m4a +0 -0
- package/assets/countdown/208.m4a +0 -0
- package/assets/countdown/209.m4a +0 -0
- package/assets/countdown/21.m4a +0 -0
- package/assets/countdown/210.m4a +0 -0
- package/assets/countdown/211.m4a +0 -0
- package/assets/countdown/212.m4a +0 -0
- package/assets/countdown/213.m4a +0 -0
- package/assets/countdown/214.m4a +0 -0
- package/assets/countdown/215.m4a +0 -0
- package/assets/countdown/216.m4a +0 -0
- package/assets/countdown/217.m4a +0 -0
- package/assets/countdown/218.m4a +0 -0
- package/assets/countdown/219.m4a +0 -0
- package/assets/countdown/22.m4a +0 -0
- package/assets/countdown/220.m4a +0 -0
- package/assets/countdown/221.m4a +0 -0
- package/assets/countdown/222.m4a +0 -0
- package/assets/countdown/223.m4a +0 -0
- package/assets/countdown/224.m4a +0 -0
- package/assets/countdown/225.m4a +0 -0
- package/assets/countdown/226.m4a +0 -0
- package/assets/countdown/227.m4a +0 -0
- package/assets/countdown/228.m4a +0 -0
- package/assets/countdown/229.m4a +0 -0
- package/assets/countdown/23.m4a +0 -0
- package/assets/countdown/230.m4a +0 -0
- package/assets/countdown/231.m4a +0 -0
- package/assets/countdown/232.m4a +0 -0
- package/assets/countdown/233.m4a +0 -0
- package/assets/countdown/234.m4a +0 -0
- package/assets/countdown/235.m4a +0 -0
- package/assets/countdown/236.m4a +0 -0
- package/assets/countdown/237.m4a +0 -0
- package/assets/countdown/238.m4a +0 -0
- package/assets/countdown/239.m4a +0 -0
- package/assets/countdown/24.m4a +0 -0
- package/assets/countdown/240.m4a +0 -0
- package/assets/countdown/25.m4a +0 -0
- package/assets/countdown/26.m4a +0 -0
- package/assets/countdown/27.m4a +0 -0
- package/assets/countdown/28.m4a +0 -0
- package/assets/countdown/29.m4a +0 -0
- package/assets/countdown/3.m4a +0 -0
- package/assets/countdown/30.m4a +0 -0
- package/assets/countdown/31.m4a +0 -0
- package/assets/countdown/32.m4a +0 -0
- package/assets/countdown/33.m4a +0 -0
- package/assets/countdown/34.m4a +0 -0
- package/assets/countdown/35.m4a +0 -0
- package/assets/countdown/36.m4a +0 -0
- package/assets/countdown/37.m4a +0 -0
- package/assets/countdown/38.m4a +0 -0
- package/assets/countdown/39.m4a +0 -0
- package/assets/countdown/4.m4a +0 -0
- package/assets/countdown/40.m4a +0 -0
- package/assets/countdown/41.m4a +0 -0
- package/assets/countdown/42.m4a +0 -0
- package/assets/countdown/43.m4a +0 -0
- package/assets/countdown/44.m4a +0 -0
- package/assets/countdown/45.m4a +0 -0
- package/assets/countdown/46.m4a +0 -0
- package/assets/countdown/47.m4a +0 -0
- package/assets/countdown/48.m4a +0 -0
- package/assets/countdown/49.m4a +0 -0
- package/assets/countdown/5.m4a +0 -0
- package/assets/countdown/50.m4a +0 -0
- package/assets/countdown/51.m4a +0 -0
- package/assets/countdown/52.m4a +0 -0
- package/assets/countdown/53.m4a +0 -0
- package/assets/countdown/54.m4a +0 -0
- package/assets/countdown/55.m4a +0 -0
- package/assets/countdown/56.m4a +0 -0
- package/assets/countdown/57.m4a +0 -0
- package/assets/countdown/58.m4a +0 -0
- package/assets/countdown/59.m4a +0 -0
- package/assets/countdown/6.m4a +0 -0
- package/assets/countdown/60.m4a +0 -0
- package/assets/countdown/61.m4a +0 -0
- package/assets/countdown/62.m4a +0 -0
- package/assets/countdown/63.m4a +0 -0
- package/assets/countdown/64.m4a +0 -0
- package/assets/countdown/65.m4a +0 -0
- package/assets/countdown/66.m4a +0 -0
- package/assets/countdown/67.m4a +0 -0
- package/assets/countdown/68.m4a +0 -0
- package/assets/countdown/69.m4a +0 -0
- package/assets/countdown/7.m4a +0 -0
- package/assets/countdown/70.m4a +0 -0
- package/assets/countdown/71.m4a +0 -0
- package/assets/countdown/72.m4a +0 -0
- package/assets/countdown/73.m4a +0 -0
- package/assets/countdown/74.m4a +0 -0
- package/assets/countdown/75.m4a +0 -0
- package/assets/countdown/76.m4a +0 -0
- package/assets/countdown/77.m4a +0 -0
- package/assets/countdown/78.m4a +0 -0
- package/assets/countdown/79.m4a +0 -0
- package/assets/countdown/8.m4a +0 -0
- package/assets/countdown/80.m4a +0 -0
- package/assets/countdown/81.m4a +0 -0
- package/assets/countdown/82.m4a +0 -0
- package/assets/countdown/83.m4a +0 -0
- package/assets/countdown/84.m4a +0 -0
- package/assets/countdown/85.m4a +0 -0
- package/assets/countdown/86.m4a +0 -0
- package/assets/countdown/87.m4a +0 -0
- package/assets/countdown/88.m4a +0 -0
- package/assets/countdown/89.m4a +0 -0
- package/assets/countdown/9.m4a +0 -0
- package/assets/countdown/90.m4a +0 -0
- package/assets/countdown/91.m4a +0 -0
- package/assets/countdown/92.m4a +0 -0
- package/assets/countdown/93.m4a +0 -0
- package/assets/countdown/94.m4a +0 -0
- package/assets/countdown/95.m4a +0 -0
- package/assets/countdown/96.m4a +0 -0
- package/assets/countdown/97.m4a +0 -0
- package/assets/countdown/98.m4a +0 -0
- package/assets/countdown/99.m4a +0 -0
- package/assets/countdown/beep.wav +0 -0
- package/assets/countdown/manifest.json +1450 -0
- package/broadcast/SampleHandler.swift +92 -0
- package/dist/CallRecord.d.ts +19 -0
- package/dist/CallRecord.js +22 -0
- package/dist/appearance.d.ts +69 -4
- package/dist/appearance.js +70 -5
- package/dist/components.d.ts +135 -0
- package/dist/components.js +185 -0
- package/dist/controller.d.mts +1 -1
- package/dist/controller.mjs +61 -7
- package/dist/countdown-assets.d.ts +1 -0
- package/dist/countdown-assets.js +244 -0
- package/dist/countdown-native.d.ts +13 -0
- package/dist/countdown-native.js +66 -0
- package/dist/countdown.d.mts +13 -0
- package/dist/countdown.mjs +72 -0
- package/dist/expo-notifications.d.ts +1 -1
- package/dist/expo-notifications.js +3 -3
- package/dist/group-phase.d.mts +4 -0
- package/dist/group-phase.mjs +26 -0
- package/dist/groups.d.ts +41 -0
- package/dist/groups.js +91 -0
- package/dist/history.d.ts +6 -15
- package/dist/history.js +3 -11
- package/dist/index.d.ts +4 -2
- package/dist/index.js +4 -2
- package/dist/native-video.d.ts +8 -0
- package/dist/native-video.js +10 -0
- package/dist/native.d.ts +2 -0
- package/dist/native.js +56 -3
- package/dist/notification-router.d.ts +2 -1
- package/dist/notification-router.js +4 -4
- package/dist/notifications.d.ts +5 -3
- package/dist/notifications.js +7 -5
- package/dist/runtime.d.ts +8 -1
- package/dist/runtime.js +10 -1
- package/dist/screens.d.ts +6 -54
- package/dist/screens.js +17 -42
- package/dist/types.d.ts +45 -1
- package/dist/versions.d.ts +2 -0
- package/dist/versions.js +3 -0
- package/dist/visual/RobonoIcon.d.ts +232 -0
- package/dist/visual/RobonoIcon.js +20 -0
- package/dist/visual/icon-nodes.d.ts +3 -0
- package/dist/visual/icon-nodes.js +2 -0
- package/dist/visual/icon-paths.d.ts +221 -0
- package/dist/visual/icon-paths.js +221 -0
- package/examples/CallingHost.tsx +16 -8
- package/examples/CustomCallingScreen.tsx +64 -0
- package/examples/ExpoGroupCallingHost.tsx +42 -0
- package/examples/GroupCallingHost.tsx +70 -0
- package/ios/RobonoCallingRuntime.m +30 -0
- package/licenses/robono-icons-lucide-license.txt +43 -0
- package/licenses/robono-icons-weather-attribution.txt +1 -0
- package/licenses/robono-icons-weather-license.txt +21 -0
- package/package.json +26 -5
- package/plugin/screensharing.cjs +39 -0
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { createAudioPlayer } from 'expo-audio';
|
|
2
|
+
import { Asset } from 'expo-asset';
|
|
3
|
+
import { Platform } from 'react-native';
|
|
4
|
+
import { createCountdownAudio } from './countdown.mjs';
|
|
5
|
+
import { countdownAssets } from './countdown-assets.js';
|
|
6
|
+
/** Private playback through the established call audio session. These recordings
|
|
7
|
+
* are never attached to the outgoing WebRTC stream. */
|
|
8
|
+
export function createNativeCountdown({ ready, ownsAudio, schedule, warnings, onError }) {
|
|
9
|
+
let revision = 0, disposed = false;
|
|
10
|
+
const players = new Map();
|
|
11
|
+
const prepared = new Map();
|
|
12
|
+
const pause = () => { revision++; warnings?.stop(); for (const p of players.values())
|
|
13
|
+
p.pause(); };
|
|
14
|
+
const prepare = (key) => { const id = String(key); let work = prepared.get(id); if (!work) {
|
|
15
|
+
if (typeof key === 'number' && key > 1)
|
|
16
|
+
for (const old of prepared.keys())
|
|
17
|
+
if (old !== '1' && old !== 'beep')
|
|
18
|
+
prepared.delete(old);
|
|
19
|
+
work = (async () => { const asset = await Asset.fromModule(countdownAssets[key]).downloadAsync(); if (!disposed && ownsAudio())
|
|
20
|
+
await warnings.prepare(id, asset.localUri); })();
|
|
21
|
+
prepared.set(id, work);
|
|
22
|
+
work.catch(() => prepared.delete(id));
|
|
23
|
+
} return work; };
|
|
24
|
+
const load = (key) => { if (typeof key === 'number' && key > 1)
|
|
25
|
+
for (const [old, player] of players)
|
|
26
|
+
if (typeof old === 'number' && old > 1 && old !== key) {
|
|
27
|
+
player.remove();
|
|
28
|
+
players.delete(old);
|
|
29
|
+
} let p = players.get(key); if (!p) {
|
|
30
|
+
const asset = countdownAssets[key];
|
|
31
|
+
if (asset === undefined)
|
|
32
|
+
throw Error('countdown_voice_unavailable');
|
|
33
|
+
p = createAudioPlayer(asset, { keepAudioSessionActive: true, updateInterval: 100 });
|
|
34
|
+
players.set(key, p);
|
|
35
|
+
} return p; };
|
|
36
|
+
const warning = createCountdownAudio({
|
|
37
|
+
schedule: schedule ?? ((fn, delay) => { const id = setTimeout(fn, delay); return () => clearTimeout(id); }), onError,
|
|
38
|
+
stop: pause,
|
|
39
|
+
async play(key) {
|
|
40
|
+
pause();
|
|
41
|
+
const version = revision, at = performance.now();
|
|
42
|
+
await ready();
|
|
43
|
+
if (disposed || version !== revision || !ownsAudio() || key === 'beep' && performance.now() - at > 700)
|
|
44
|
+
return;
|
|
45
|
+
if (Platform.OS === 'android') {
|
|
46
|
+
if (!warnings)
|
|
47
|
+
throw Error('calling_warning_native_build_required');
|
|
48
|
+
await Promise.all([prepare(1), prepare('beep'), prepare(key)]);
|
|
49
|
+
if (!disposed && version === revision && ownsAudio() && (key !== 'beep' || performance.now() - at < 700))
|
|
50
|
+
await warnings.play(String(key));
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
// Decode the final cues early, while the initial announcement is playing.
|
|
54
|
+
load(1);
|
|
55
|
+
load('beep');
|
|
56
|
+
const player = load(key);
|
|
57
|
+
if (player.isLoaded || player.currentTime > 0)
|
|
58
|
+
await player.seekTo(0);
|
|
59
|
+
if (!disposed && version === revision && ownsAudio())
|
|
60
|
+
player.play();
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
return { update(call) { if (!call)
|
|
64
|
+
prepared.clear(); warning.update(call); }, dispose() { disposed = true; warning.dispose(); prepared.clear(); for (const p of players.values())
|
|
65
|
+
p.remove(); players.clear(); } };
|
|
66
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** Anchor server remaining time to the local monotonic clock. Repeated snapshots
|
|
2
|
+
* cannot replay announcements or extend the deadline. Native schedule supports
|
|
3
|
+
* screen-off calls; overdue cues are skipped instead of bursting on resume. */
|
|
4
|
+
export function createCountdownAudio({ play, stop, schedule, now, onError }: {
|
|
5
|
+
play: any;
|
|
6
|
+
stop: any;
|
|
7
|
+
schedule: any;
|
|
8
|
+
now?: (() => number) | undefined;
|
|
9
|
+
onError?: ((error: any) => void) | undefined;
|
|
10
|
+
}): {
|
|
11
|
+
update(call: any): void;
|
|
12
|
+
dispose(): void;
|
|
13
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/** Anchor server remaining time to the local monotonic clock. Repeated snapshots
|
|
2
|
+
* cannot replay announcements or extend the deadline. Native schedule supports
|
|
3
|
+
* screen-off calls; overdue cues are skipped instead of bursting on resume. */
|
|
4
|
+
export function createCountdownAudio({ play, stop, schedule, now = () => performance.now(), onError = error => { } }) {
|
|
5
|
+
let id = null, deadline = 0, cancel, muted = false, disposed = false, spoken = new Set(), initial = null;
|
|
6
|
+
const clear = () => { cancel?.(); cancel = undefined; };
|
|
7
|
+
const cue = (key, value) => { if (spoken.has(key))
|
|
8
|
+
return; spoken.add(key); if (!muted)
|
|
9
|
+
Promise.resolve(play(value)).catch(onError); };
|
|
10
|
+
const tick = () => {
|
|
11
|
+
clear();
|
|
12
|
+
if (!id || disposed)
|
|
13
|
+
return;
|
|
14
|
+
const remaining = deadline - now();
|
|
15
|
+
if (remaining <= 0) {
|
|
16
|
+
stop();
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
if (initial !== null) {
|
|
20
|
+
cue('initial', initial);
|
|
21
|
+
if (initial === 1)
|
|
22
|
+
spoken.add('minute');
|
|
23
|
+
initial = null;
|
|
24
|
+
}
|
|
25
|
+
if (remaining <= 60000 && !spoken.has('minute')) {
|
|
26
|
+
if (remaining > 58500)
|
|
27
|
+
cue('minute', 1);
|
|
28
|
+
else
|
|
29
|
+
spoken.add('minute');
|
|
30
|
+
}
|
|
31
|
+
for (let second = 5; second >= 1; second--)
|
|
32
|
+
if (remaining <= second * 1000 && !spoken.has('beep' + second)) {
|
|
33
|
+
if (remaining > second * 1000 - 700)
|
|
34
|
+
cue('beep' + second, 'beep');
|
|
35
|
+
else
|
|
36
|
+
spoken.add('beep' + second);
|
|
37
|
+
}
|
|
38
|
+
const next = [60000, 5000, 4000, 3000, 2000, 1000, 0].find(t => remaining > t + 1) ?? 0;
|
|
39
|
+
cancel = schedule(tick, Math.max(1, remaining - next));
|
|
40
|
+
};
|
|
41
|
+
return {
|
|
42
|
+
update(call) {
|
|
43
|
+
if (disposed)
|
|
44
|
+
return;
|
|
45
|
+
const t = call?.countdown;
|
|
46
|
+
if (!t || call.state !== 'connected' || !call.controlled || call.memberState && call.memberState !== 'joined' || !t.audible) {
|
|
47
|
+
clear();
|
|
48
|
+
if (id)
|
|
49
|
+
stop();
|
|
50
|
+
id = null;
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
if (!Number.isFinite(t.remainingMs) || t.remainingMs < 0)
|
|
54
|
+
return;
|
|
55
|
+
muted = !!call.localHeld;
|
|
56
|
+
if (t.id !== id) {
|
|
57
|
+
clear();
|
|
58
|
+
stop();
|
|
59
|
+
id = t.id;
|
|
60
|
+
deadline = now() + t.remainingMs;
|
|
61
|
+
spoken = new Set();
|
|
62
|
+
initial = t.remainingMs > 5000 ? Math.max(1, Math.min(t.minutes, Math.ceil(t.remainingMs / 60000))) : null;
|
|
63
|
+
}
|
|
64
|
+
else
|
|
65
|
+
deadline = Math.min(deadline, now() + t.remainingMs);
|
|
66
|
+
if (muted)
|
|
67
|
+
stop();
|
|
68
|
+
tick();
|
|
69
|
+
},
|
|
70
|
+
dispose() { disposed = true; id = null; clear(); stop(); }
|
|
71
|
+
};
|
|
72
|
+
}
|
|
@@ -2,7 +2,7 @@ import * as Notifications from 'expo-notifications';
|
|
|
2
2
|
import { type CallingNotificationRouterOptions } from './notification-router.js';
|
|
3
3
|
export { callingNotificationPresentation } from './notification-router.js';
|
|
4
4
|
/** Compose explicitly with your existing handler; preserve ordinary message alerts. */
|
|
5
|
-
export declare function withCallingNotificationPresentation(handler: Notifications.NotificationHandler, canPresentCall: () => boolean): Notifications.NotificationHandler;
|
|
5
|
+
export declare function withCallingNotificationPresentation(handler: Notifications.NotificationHandler, canPresentCall: () => boolean, group?: boolean): Notifications.NotificationHandler;
|
|
6
6
|
/** Registers listeners, never replaces the app's global presentation handler. */
|
|
7
7
|
export declare function connectExpoCallingNotifications(options: Omit<CallingNotificationRouterOptions, 'dismiss'> & {
|
|
8
8
|
onError(error: Error): void;
|
|
@@ -3,9 +3,9 @@ import { AppState } from 'react-native';
|
|
|
3
3
|
import { createCallingNotificationRouter, callingNotificationPresentation } from './notification-router.js';
|
|
4
4
|
export { callingNotificationPresentation } from './notification-router.js';
|
|
5
5
|
/** Compose explicitly with your existing handler; preserve ordinary message alerts. */
|
|
6
|
-
export function withCallingNotificationPresentation(handler, canPresentCall) {
|
|
6
|
+
export function withCallingNotificationPresentation(handler, canPresentCall, group = false) {
|
|
7
7
|
return { ...handler, handleNotification: async (notification) => {
|
|
8
|
-
const decision = callingNotificationPresentation(notification.request.content.data, AppState.currentState === 'active');
|
|
8
|
+
const decision = callingNotificationPresentation(notification.request.content.data, AppState.currentState === 'active', group);
|
|
9
9
|
if (decision === 'dismiss' || decision === 'screen' && canPresentCall())
|
|
10
10
|
return { shouldPlaySound: false, shouldSetBadge: false, shouldShowBanner: false, shouldShowList: false };
|
|
11
11
|
return handler.handleNotification(notification);
|
|
@@ -27,7 +27,7 @@ export function connectExpoCallingNotifications(options) {
|
|
|
27
27
|
if (disposed || !value || value.actionIdentifier !== Notifications.DEFAULT_ACTION_IDENTIFIER)
|
|
28
28
|
return;
|
|
29
29
|
const data = value.notification.request.content.data;
|
|
30
|
-
if (!callingNotificationPresentation(data, false))
|
|
30
|
+
if (!callingNotificationPresentation(data, false, options.group))
|
|
31
31
|
return;
|
|
32
32
|
if (await router.handle(data, true)) {
|
|
33
33
|
// Don't clear a different notification that arrived while storage was read.
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Presentation follows this device's participation, not another member's call. */
|
|
2
|
+
export function groupPhase(snapshot: any, pending?: boolean): "incoming" | "outgoing" | "connecting" | "connected" | "held" | "idle" | "error";
|
|
3
|
+
/** Media may connect before the service acknowledges the group connection. */
|
|
4
|
+
export function groupCanShare(snapshot: any): boolean;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** Presentation follows this device's participation, not another member's call. */
|
|
2
|
+
export function groupPhase(snapshot, pending = false) {
|
|
3
|
+
const call = snapshot.call;
|
|
4
|
+
if (call && (call.controlled === false || call.state === 'ended' || ['left', 'declined'].includes(call.memberState)))
|
|
5
|
+
return 'idle';
|
|
6
|
+
if (snapshot.localHeld)
|
|
7
|
+
return 'held';
|
|
8
|
+
if (snapshot.connectedAt != null)
|
|
9
|
+
return 'connected';
|
|
10
|
+
if (snapshot.preparing)
|
|
11
|
+
return call?.memberState === 'invited' || call?.state === 'connecting' ? 'connecting' : 'outgoing';
|
|
12
|
+
if (call?.memberState === 'invited')
|
|
13
|
+
return 'incoming';
|
|
14
|
+
if (call?.memberState === 'joined')
|
|
15
|
+
return call.state === 'ringing' ? 'outgoing' : 'connecting';
|
|
16
|
+
if (pending)
|
|
17
|
+
return 'outgoing';
|
|
18
|
+
return snapshot.error ? 'error' : 'idle';
|
|
19
|
+
}
|
|
20
|
+
/** Media may connect before the service acknowledges the group connection. */
|
|
21
|
+
export function groupCanShare(snapshot) {
|
|
22
|
+
const call = snapshot.call;
|
|
23
|
+
return !!(call?.controlled && call.state === 'connected' && call.memberState === 'joined'
|
|
24
|
+
&& call.kind === 'video' && call.screenSharingAvailable
|
|
25
|
+
&& !snapshot.localHeld && !call.localHeld && !call.remoteHeld);
|
|
26
|
+
}
|
package/dist/groups.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { RobonoGroupCallingClient } from '@robono/calling/groups';
|
|
3
|
+
import { type CallingScreenProps } from './screens.js';
|
|
4
|
+
import type { CallingOptions, CallingState, Contact } from './types.js';
|
|
5
|
+
export interface GroupCallingOptions extends Omit<CallingOptions, 'resolveContact' | 'onUnansweredCall'> {
|
|
6
|
+
resolveGroup?: (connectionId: string) => Contact | null;
|
|
7
|
+
resolveMember?: (appId: string, userId: string) => Contact | null;
|
|
8
|
+
}
|
|
9
|
+
export declare function createGroupCallingController(options: GroupCallingOptions): {
|
|
10
|
+
client: RobonoGroupCallingClient;
|
|
11
|
+
getSnapshot: () => CallingState;
|
|
12
|
+
subscribe: (fn: () => void) => () => void;
|
|
13
|
+
listen(): Promise<void>;
|
|
14
|
+
reportComponents(values: string[]): void;
|
|
15
|
+
call(connectionId: string, input?: {
|
|
16
|
+
kind?: "voice" | "video";
|
|
17
|
+
}): Promise<void>;
|
|
18
|
+
answer(): Promise<void>;
|
|
19
|
+
refresh: () => Promise<boolean>;
|
|
20
|
+
openIncoming(callId: string): Promise<boolean>;
|
|
21
|
+
hangUp(input?: {
|
|
22
|
+
playEndTone?: boolean;
|
|
23
|
+
}): Promise<void>;
|
|
24
|
+
mute: (value: boolean) => void;
|
|
25
|
+
setCamera: (value: boolean) => void;
|
|
26
|
+
startScreenSharing: () => Promise<void>;
|
|
27
|
+
stopScreenSharing: () => Promise<void>;
|
|
28
|
+
switchCamera(): Promise<void>;
|
|
29
|
+
setSpeaker(value: boolean): void;
|
|
30
|
+
setForeground(value: boolean): void;
|
|
31
|
+
interrupt(): Promise<void>;
|
|
32
|
+
resume(): Promise<void>;
|
|
33
|
+
dismissError(): void;
|
|
34
|
+
dispose(): Promise<void>;
|
|
35
|
+
};
|
|
36
|
+
export type GroupCallingController = ReturnType<typeof createGroupCallingController>;
|
|
37
|
+
export interface GroupCallingOverlayProps extends Omit<CallingScreenProps, 'state' | 'onAnswer' | 'onHangUp' | 'onMute' | 'onSpeaker' | 'onClose'> {
|
|
38
|
+
controller: GroupCallingController;
|
|
39
|
+
}
|
|
40
|
+
/** Optional group screen. Use the engine alone when keeping your own interface. */
|
|
41
|
+
export declare function GroupCallingOverlay({ controller, ...props }: GroupCallingOverlayProps): React.JSX.Element;
|
package/dist/groups.js
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { engineVersion, mobileVersion } from './versions.js';
|
|
3
|
+
import { useEffect, useSyncExternalStore } from 'react';
|
|
4
|
+
import { AppState, Modal, Platform } from 'react-native';
|
|
5
|
+
import { SafeAreaProvider } from 'react-native-safe-area-context';
|
|
6
|
+
import { RobonoGroupCallingClient } from '@robono/calling/groups';
|
|
7
|
+
import { CallingScreen } from './screens.js';
|
|
8
|
+
import { groupPhase, groupCanShare } from './group-phase.mjs';
|
|
9
|
+
export function createGroupCallingController(options) {
|
|
10
|
+
let state = { group: true, phase: 'idle', call: null, contact: null, speaker: false, muted: false, canMute: false, canSpeaker: true, connectedAt: null, error: null };
|
|
11
|
+
const listeners = new Set();
|
|
12
|
+
let foreground = true, pendingKind = 'voice', pending = false, suppressEnd = false;
|
|
13
|
+
const emit = () => listeners.forEach(fn => fn());
|
|
14
|
+
const report = (e) => options.onError?.(e instanceof Error ? e : Error(String(e)));
|
|
15
|
+
const sound = (endTone = false) => void Promise.resolve(options.audio.update({ phase: state.phase, speaker: state.speaker, foreground, endTone, localHeld: state.localHeld })).catch(report);
|
|
16
|
+
const apply = (snapshot) => {
|
|
17
|
+
const c = snapshot.call, old = state.phase;
|
|
18
|
+
const phase = groupPhase(snapshot, pending);
|
|
19
|
+
state = { ...state, screenSharing: snapshot.screenSharing, screenSharePending: snapshot.screenSharePending, displayStream: snapshot.displayStream, canScreenShare: groupCanShare(snapshot), phase, kind: c?.kind ?? pendingKind, error: snapshot.error, muted: snapshot.muted, localHeld: snapshot.localHeld,
|
|
20
|
+
holdExpiresAt: c?.holdExpiresAt, canMute: !!snapshot.localStream, canSpeaker: true, canCamera: !!snapshot.localStream, cameraEnabled: snapshot.cameraEnabled, localStream: snapshot.localStream,
|
|
21
|
+
contact: c ? options.resolveGroup?.(c.connectionId) ?? { name: 'Group call' } : state.contact, connectedAt: snapshot.connectedAt,
|
|
22
|
+
groupMembers: c?.members.map(m => ({ ...options.resolveMember?.(m.appId, m.userId), id: m.id, name: m.id === c.self ? 'You' : options.resolveMember?.(m.appId, m.userId)?.name ?? 'Participant', state: m.state, held: m.held, local: m.id === c.self, sharing: !!c.sharing?.[m.id], stream: m.id === c.self ? snapshot.displayStream || snapshot.localStream : snapshot.remoteStreams[m.id] })) };
|
|
23
|
+
sound(!suppressEnd && old === 'connected' && phase === 'idle');
|
|
24
|
+
options.audio.countdown?.(c ? { ...c, localHeld: !!snapshot.localHeld || !!c.localHeld } : null);
|
|
25
|
+
emit();
|
|
26
|
+
};
|
|
27
|
+
const components = new Set(['controller', ...(options.media.robonoAdapter ? ['native-media'] : []), ...(options.audio.robonoAdapter ? ['native-audio'] : [])]);
|
|
28
|
+
const inventory = () => void options.request('client-info', { platform: Platform.OS, engineVersion, mobileVersion, components: [...components], appearanceRevision: options.appearanceRevision }).catch(report);
|
|
29
|
+
const client = new RobonoGroupCallingClient({ ...options.media, request: options.request, forceRelay: options.forceRelay, onChange: apply });
|
|
30
|
+
return { client, getSnapshot: () => state, subscribe: (fn) => { listeners.add(fn); return () => { listeners.delete(fn); }; },
|
|
31
|
+
async listen() { await client.listen(); inventory(); },
|
|
32
|
+
reportComponents(values) { values.forEach(v => components.add(v)); inventory(); },
|
|
33
|
+
async call(connectionId, input = {}) { pendingKind = input.kind ?? 'voice'; pending = true; state = { ...state, contact: options.resolveGroup?.(connectionId) ?? { name: 'Group call' }, kind: pendingKind, phase: 'outgoing' }; sound(); emit(); try {
|
|
34
|
+
await client.call(connectionId, input);
|
|
35
|
+
}
|
|
36
|
+
finally {
|
|
37
|
+
pending = false;
|
|
38
|
+
apply(client.state);
|
|
39
|
+
} },
|
|
40
|
+
async answer() { state = { ...state, phase: 'connecting' }; sound(); emit(); await client.answer(); },
|
|
41
|
+
refresh: () => client.refresh(),
|
|
42
|
+
async openIncoming(callId) {
|
|
43
|
+
if (state.phase === 'idle') {
|
|
44
|
+
state = { ...state, phase: 'loading', error: null };
|
|
45
|
+
emit();
|
|
46
|
+
}
|
|
47
|
+
const ok = await client.refresh(), matches = ok && client.state.call?.id === callId && client.state.call.controlled && client.state.call.state !== 'ended' && client.state.call.memberState === 'invited';
|
|
48
|
+
if (!matches && state.phase === 'loading') {
|
|
49
|
+
state = { ...state, phase: 'error', error: 'call_unavailable' };
|
|
50
|
+
emit();
|
|
51
|
+
}
|
|
52
|
+
return !!matches;
|
|
53
|
+
},
|
|
54
|
+
async hangUp(input) { options.audio.countdown?.(null); suppressEnd = input?.playEndTone === false; try {
|
|
55
|
+
await client.leave();
|
|
56
|
+
}
|
|
57
|
+
finally {
|
|
58
|
+
suppressEnd = false;
|
|
59
|
+
} }, mute: (value) => client.mute(value), setCamera: (value) => client.setCamera(value),
|
|
60
|
+
startScreenSharing: () => client.startScreenSharing(), stopScreenSharing: () => client.stopScreenSharing(),
|
|
61
|
+
async switchCamera() { if (client.state.localStream)
|
|
62
|
+
await options.media.switchCamera?.(client.state.localStream); },
|
|
63
|
+
setSpeaker(value) { state = { ...state, speaker: value }; sound(); emit(); },
|
|
64
|
+
setForeground(value) { foreground = value; client.setForeground(value); sound(); },
|
|
65
|
+
async interrupt() { await client.hold(); }, async resume() { if (state.resumePending)
|
|
66
|
+
return; state = { ...state, resumePending: true, resumeError: null }; emit(); try {
|
|
67
|
+
await client.resume(() => Promise.resolve(options.audio.resume?.()));
|
|
68
|
+
}
|
|
69
|
+
catch (e) {
|
|
70
|
+
state = { ...state, resumeError: e instanceof Error ? e.message : String(e) };
|
|
71
|
+
throw e;
|
|
72
|
+
}
|
|
73
|
+
finally {
|
|
74
|
+
state = { ...state, resumePending: false };
|
|
75
|
+
emit();
|
|
76
|
+
} },
|
|
77
|
+
dismissError() { state = { ...state, error: null, phase: 'idle' }; emit(); },
|
|
78
|
+
async dispose() { try {
|
|
79
|
+
await client.dispose();
|
|
80
|
+
}
|
|
81
|
+
finally {
|
|
82
|
+
await options.audio.dispose();
|
|
83
|
+
listeners.clear();
|
|
84
|
+
} } };
|
|
85
|
+
}
|
|
86
|
+
/** Optional group screen. Use the engine alone when keeping your own interface. */
|
|
87
|
+
export function GroupCallingOverlay({ controller, ...props }) {
|
|
88
|
+
const state = useSyncExternalStore(controller.subscribe, controller.getSnapshot, controller.getSnapshot);
|
|
89
|
+
useEffect(() => { controller.reportComponents(['screens']); controller.setForeground(AppState.currentState === 'active'); const s = AppState.addEventListener('change', v => controller.setForeground(v === 'active')); return () => s.remove(); }, [controller]);
|
|
90
|
+
return _jsx(Modal, { visible: state.phase !== 'idle', animationType: "none", presentationStyle: "fullScreen", onRequestClose: () => { void controller.hangUp().catch(() => { }); }, children: _jsx(SafeAreaProvider, { children: _jsx(CallingScreen, { ...props, state: state, onAnswer: () => { void controller.answer().catch(() => { }); }, onHangUp: () => { void controller.hangUp().catch(() => { }); }, onMute: controller.mute, onSpeaker: controller.setSpeaker, onScreenShare: () => { void (state.screenSharing ? controller.stopScreenSharing() : controller.startScreenSharing()).catch(() => { }); }, onCamera: controller.setCamera, onSwitchCamera: () => { void controller.switchCamera().catch(() => { }); }, onResume: () => { void controller.resume().catch(() => { }); }, onClose: controller.dismissError }) }) });
|
|
91
|
+
}
|
package/dist/history.d.ts
CHANGED
|
@@ -1,16 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
textColor?: string;
|
|
9
|
-
/** Caller must recheck live availability before placing the callback. */
|
|
10
|
-
onCallBack?: () => void;
|
|
11
|
-
label?: (entry: CallHistoryEntry) => {
|
|
12
|
-
label: string;
|
|
13
|
-
detail: string;
|
|
14
|
-
missed: boolean;
|
|
15
|
-
};
|
|
16
|
-
}): React.JSX.Element;
|
|
2
|
+
import { CallRecord } from './CallRecord.js';
|
|
3
|
+
type Props = Omit<React.ComponentProps<typeof CallRecord>, 'label'> & {
|
|
4
|
+
label?: React.ComponentProps<typeof CallRecord>['label'];
|
|
5
|
+
};
|
|
6
|
+
export declare function CallHistoryItem({ label, ...props }: Props): React.JSX.Element;
|
|
7
|
+
export {};
|
package/dist/history.js
CHANGED
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
import { jsx as _jsx
|
|
2
|
-
import { Pressable, StyleSheet, Text, View } from 'react-native';
|
|
3
|
-
import Svg, { Path } from 'react-native-svg';
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
2
|
import { describeCall } from '@robono/calling/history';
|
|
5
|
-
|
|
6
|
-
export function CallHistoryItem({
|
|
7
|
-
const description = label ? label(entry) : describeCall(entry);
|
|
8
|
-
const incoming = entry.role === 'callee';
|
|
9
|
-
const body = _jsxs(View, { style: [styles.bubble, { backgroundColor: incoming ? incomingColor : outgoingColor }], children: [_jsx(Svg, { width: 24, height: 24, viewBox: "0 0 24 24", accessible: false, children: _jsx(Path, { d: description.missed ? 'M4 5v6h6M4 11l6-6 7 7 4-4' : incoming ? 'M18 5 6 17M6 10v7h7' : 'M6 18 18 6M11 6h7v7', stroke: textColor, strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", fill: "none" }) }), _jsxs(View, { style: styles.text, children: [_jsx(Text, { style: [styles.title, { color: textColor }], children: description.label }), !!description.detail && _jsx(Text, { style: { color: textColor }, children: description.detail })] })] });
|
|
10
|
-
return _jsx(View, { style: { alignItems: incoming ? 'flex-start' : 'flex-end', marginVertical: 4 }, children: onCallBack ? _jsx(Pressable, { onPress: onCallBack, accessibilityRole: "button", accessibilityLabel: `${description.label}. ${description.detail}`, accessibilityHint: "Call this contact", style: styles.width, children: body }) : body });
|
|
11
|
-
}
|
|
12
|
-
const styles = StyleSheet.create({ bubble: { borderRadius: 16, padding: 14, flexDirection: 'row', alignItems: 'center', gap: 12, maxWidth: '85%' }, width: { maxWidth: '100%' }, text: { flexShrink: 1, gap: 4 }, title: { fontSize: 16, fontWeight: '500' } });
|
|
3
|
+
import { CallRecord } from './CallRecord.js';
|
|
4
|
+
export function CallHistoryItem({ label = describeCall, ...props }) { return _jsx(CallRecord, { ...props, label: label }); }
|
package/dist/index.d.ts
CHANGED
|
@@ -4,5 +4,7 @@ export { CallingScreen, CallingOverlay, useCalling } from './screens.js';
|
|
|
4
4
|
export { CallHistoryItem } from './history.js';
|
|
5
5
|
export type { CallingScreenProps, CallingOverlayProps, CallingLabels, CallingTheme } from './screens.js';
|
|
6
6
|
export type { CallAudio, CallingState, CallingController, CallingOptions, Contact, MediaAdapter, Phase } from './types.js';
|
|
7
|
-
export { callingInk, defaultCallingAppearance, validateCallingAppearance, soundCatalog } from './appearance.js';
|
|
8
|
-
export type { CallingAppearance, SoundChoice, SoundEvent } from './appearance.js';
|
|
7
|
+
export { callingInk, resolveCallingDesign, defaultCallingAppearance, validateCallingAppearance, soundCatalog } from './appearance.js';
|
|
8
|
+
export type { CallingAppearance, CallingPresentation, SoundChoice, SoundEvent } from './appearance.js';
|
|
9
|
+
export { CallingUIProvider, useCallingUI, CallingLayout, CallingBrand, CallingAvatar, CallingContact, CallingStatus, CallingIdentity, CallingVideo, CallingActionButton, CallingAudioControls, CallingIncomingControls, CallingControls, } from './components.js';
|
|
10
|
+
export type { CallingUIProviderProps, CallingUIValue, CallingScreenComponents, CallingAction, CallingActionModel, CallingSectionProps, CallingLayoutProps, CallingAvatarProps, CallingContactProps, CallingStatusProps, CallingActionButtonProps, } from './components.js';
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { engineVersion, mobileVersion } from './versions.js';
|
|
1
2
|
import { RobonoCallingClient } from '@robono/calling';
|
|
2
3
|
import { createController } from './controller.mjs';
|
|
3
4
|
import { Platform } from 'react-native';
|
|
@@ -12,7 +13,7 @@ export function createCallingController(options) {
|
|
|
12
13
|
return;
|
|
13
14
|
sent = key;
|
|
14
15
|
// Inventory is explicitly client-declared; it cannot set charges or access.
|
|
15
|
-
void Promise.resolve().then(() => options.request('client-info', { platform: Platform.OS, engineVersion
|
|
16
|
+
void Promise.resolve().then(() => options.request('client-info', { platform: Platform.OS, engineVersion, mobileVersion, components: [...components].sort(), appearanceRevision: options.appearanceRevision })).catch(() => { sent = ''; });
|
|
16
17
|
};
|
|
17
18
|
const listen = controller.listen;
|
|
18
19
|
controller.listen = async () => { await listen(); controller.reportComponents?.([]); };
|
|
@@ -20,4 +21,5 @@ export function createCallingController(options) {
|
|
|
20
21
|
}
|
|
21
22
|
export { CallingScreen, CallingOverlay, useCalling } from './screens.js';
|
|
22
23
|
export { CallHistoryItem } from './history.js';
|
|
23
|
-
export { callingInk, defaultCallingAppearance, validateCallingAppearance, soundCatalog } from './appearance.js';
|
|
24
|
+
export { callingInk, resolveCallingDesign, defaultCallingAppearance, validateCallingAppearance, soundCatalog } from './appearance.js';
|
|
25
|
+
export { CallingUIProvider, useCallingUI, CallingLayout, CallingBrand, CallingAvatar, CallingContact, CallingStatus, CallingIdentity, CallingVideo, CallingActionButton, CallingAudioControls, CallingIncomingControls, CallingControls, } from './components.js';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type CallingOverlayProps } from './screens.js';
|
|
3
|
+
import type { CallingScreenProps } from './components.js';
|
|
4
|
+
export declare const renderNativeCallVideo: NonNullable<CallingScreenProps['renderVideo']>;
|
|
5
|
+
/** Optional complete native screen; the calling engine can also use your UI. */
|
|
6
|
+
export declare function NativeCallingOverlay(props: CallingOverlayProps): React.JSX.Element;
|
|
7
|
+
import { type GroupCallingOverlayProps } from './groups.js';
|
|
8
|
+
export declare function NativeGroupCallingOverlay(props: GroupCallingOverlayProps): React.JSX.Element;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { RTCView } from 'react-native-webrtc';
|
|
3
|
+
import { CallingOverlay } from './screens.js';
|
|
4
|
+
export const renderNativeCallVideo = ({ stream, local, screen, style }) => _jsx(RTCView, { streamURL: stream.toURL(), mirror: local && !screen, objectFit: screen ? "contain" : "cover", zOrder: local ? 1 : 0, style: style });
|
|
5
|
+
/** Optional complete native screen; the calling engine can also use your UI. */
|
|
6
|
+
export function NativeCallingOverlay(props) {
|
|
7
|
+
return _jsx(CallingOverlay, { ...props, renderVideo: props.renderVideo || renderNativeCallVideo });
|
|
8
|
+
}
|
|
9
|
+
import { GroupCallingOverlay } from './groups.js';
|
|
10
|
+
export function NativeGroupCallingOverlay(props) { return _jsx(GroupCallingOverlay, { ...props, renderVideo: props.renderVideo || renderNativeCallVideo }); }
|
package/dist/native.d.ts
CHANGED
|
@@ -11,6 +11,8 @@ export interface NativeAdapterOptions {
|
|
|
11
11
|
/** Supplied native runtime, or your existing application's lifetime adapter. */
|
|
12
12
|
runtime?: CallRuntime;
|
|
13
13
|
}
|
|
14
|
+
/** True while this adapter owns ringing or call audio. Use as the messaging audio session guard. */
|
|
15
|
+
export declare function isNativeCallAudioActive(): boolean;
|
|
14
16
|
/** Import this entry point only when choosing the supplied native audio adapter. */
|
|
15
17
|
export declare function createNativeCallAdapters(options: NativeAdapterOptions): {
|
|
16
18
|
media: MediaAdapter;
|
package/dist/native.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createNativeCountdown } from './countdown-native.js';
|
|
2
|
+
import { PermissionsAndroid, Platform, NativeModules } from 'react-native';
|
|
2
3
|
import { mediaDevices, MediaStream, RTCPeerConnection } from 'react-native-webrtc';
|
|
3
4
|
import InCallManager from 'react-native-incall-manager';
|
|
4
5
|
import { createAudioPlayer, setAudioModeAsync } from 'expo-audio';
|
|
@@ -6,6 +7,8 @@ import { randomUUID } from 'expo-crypto';
|
|
|
6
7
|
import { createCallAudio } from './audio.mjs';
|
|
7
8
|
import { callingSounds } from './appearance.js';
|
|
8
9
|
let audioOwner = null;
|
|
10
|
+
/** True while this adapter owns ringing or call audio. Use as the messaging audio session guard. */
|
|
11
|
+
export function isNativeCallAudioActive() { return audioOwner !== null; }
|
|
9
12
|
/** Import this entry point only when choosing the supplied native audio adapter. */
|
|
10
13
|
export function createNativeCallAdapters(options) {
|
|
11
14
|
if (Platform.OS !== 'ios' && Platform.OS !== 'android')
|
|
@@ -99,6 +102,7 @@ export function createNativeCallAdapters(options) {
|
|
|
99
102
|
player.play();
|
|
100
103
|
},
|
|
101
104
|
async release() {
|
|
105
|
+
countdown.update(null);
|
|
102
106
|
pause();
|
|
103
107
|
if (audioOwner !== owner)
|
|
104
108
|
return;
|
|
@@ -125,15 +129,57 @@ export function createNativeCallAdapters(options) {
|
|
|
125
129
|
audioOwner = null;
|
|
126
130
|
}
|
|
127
131
|
},
|
|
128
|
-
dispose() { disposed = true; pause(); if (players)
|
|
132
|
+
dispose() { disposed = true; countdown.dispose(); pause(); if (players)
|
|
129
133
|
Object.values(players).forEach(player => player.remove()); players = undefined; },
|
|
130
134
|
});
|
|
135
|
+
const countdown = createNativeCountdown({ ready: () => audio.ready(), ownsAudio: () => audioOwner === owner && !disposed && session === 'call', schedule: options.runtime?.schedule, warnings: options.runtime?.warnings, onError: options.onError });
|
|
136
|
+
audio.countdown = countdown.update;
|
|
131
137
|
audio.robonoAdapter = true;
|
|
132
138
|
const media = {
|
|
133
139
|
robonoAdapter: true,
|
|
134
140
|
createId: randomUUID,
|
|
135
141
|
createPeerConnection: config => new RTCPeerConnection(config),
|
|
136
142
|
createRemoteStream: track => new MediaStream([track]),
|
|
143
|
+
async getDisplayMedia(context) {
|
|
144
|
+
const current = () => !disposed && (!context || context.isCurrent());
|
|
145
|
+
if (!current())
|
|
146
|
+
throw Error('call_cancelled');
|
|
147
|
+
const native = NativeModules.RobonoCallingRuntime;
|
|
148
|
+
if (typeof native?.screenSharingPrepare !== 'function')
|
|
149
|
+
throw Error('screen_sharing_native_build_required');
|
|
150
|
+
await native.screenSharingPrepare();
|
|
151
|
+
if (!current())
|
|
152
|
+
throw Error('call_cancelled');
|
|
153
|
+
const stream = await mediaDevices.getDisplayMedia({});
|
|
154
|
+
if (Platform.OS === 'ios')
|
|
155
|
+
try {
|
|
156
|
+
await native.screenSharingStart();
|
|
157
|
+
const started = Date.now();
|
|
158
|
+
while (true) {
|
|
159
|
+
if (!current())
|
|
160
|
+
throw Error('call_cancelled');
|
|
161
|
+
const status = await native.screenSharingStatus();
|
|
162
|
+
if (status.active && status.at >= started - 1000)
|
|
163
|
+
break;
|
|
164
|
+
if (Date.now() - started > 30000)
|
|
165
|
+
throw Error('screen_capture_cancelled');
|
|
166
|
+
await new Promise(resolve => setTimeout(resolve, 250));
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
catch (e) {
|
|
170
|
+
stream.getTracks().forEach(t => t.stop());
|
|
171
|
+
throw e;
|
|
172
|
+
}
|
|
173
|
+
if (!current()) {
|
|
174
|
+
stream.getTracks().forEach(t => t.stop());
|
|
175
|
+
throw Error('call_cancelled');
|
|
176
|
+
}
|
|
177
|
+
return stream;
|
|
178
|
+
},
|
|
179
|
+
switchCamera(stream) {
|
|
180
|
+
const track = stream.getVideoTracks()[0];
|
|
181
|
+
track?._switchCamera();
|
|
182
|
+
},
|
|
137
183
|
async getUserMedia(context) {
|
|
138
184
|
const current = () => !disposed && (!context || context.isCurrent());
|
|
139
185
|
if (!current())
|
|
@@ -145,6 +191,13 @@ export function createNativeCallAdapters(options) {
|
|
|
145
191
|
if (result !== PermissionsAndroid.RESULTS.GRANTED)
|
|
146
192
|
throw Error('microphone_permission_denied');
|
|
147
193
|
}
|
|
194
|
+
if (Platform.OS === 'android' && context?.kind === 'video') {
|
|
195
|
+
const result = await PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.CAMERA);
|
|
196
|
+
if (!current())
|
|
197
|
+
throw Error('call_cancelled');
|
|
198
|
+
if (result !== PermissionsAndroid.RESULTS.GRANTED)
|
|
199
|
+
throw Error('camera_permission_denied');
|
|
200
|
+
}
|
|
148
201
|
await audio.ready();
|
|
149
202
|
if (!current())
|
|
150
203
|
throw Error('call_cancelled');
|
|
@@ -155,7 +208,7 @@ export function createNativeCallAdapters(options) {
|
|
|
155
208
|
}
|
|
156
209
|
let stream;
|
|
157
210
|
try {
|
|
158
|
-
stream = await mediaDevices.getUserMedia({ audio: true, video: false });
|
|
211
|
+
stream = await mediaDevices.getUserMedia({ audio: true, video: context?.kind === 'video' ? { facingMode: 'user', width: context?.videoQuality === '480p' ? 854 : 1280, height: context?.videoQuality === '480p' ? 480 : 720, frameRate: 24 } : false });
|
|
159
212
|
}
|
|
160
213
|
catch (error) {
|
|
161
214
|
await options.runtime?.end();
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type NotificationStore } from './notifications.js';
|
|
2
2
|
export interface CallingNotificationRouterOptions {
|
|
3
3
|
accountKey: string;
|
|
4
|
+
group?: boolean;
|
|
4
5
|
/** Resolve your backend's recipient field; never infer identity from a call ID. */
|
|
5
6
|
recipientAccount(data: unknown): string | null;
|
|
6
7
|
store: NotificationStore;
|
|
@@ -15,4 +16,4 @@ export declare function createCallingNotificationRouter(options: CallingNotifica
|
|
|
15
16
|
dispose(): void;
|
|
16
17
|
};
|
|
17
18
|
/** Provider-neutral presentation decision; leave unrelated notifications alone. */
|
|
18
|
-
export declare function callingNotificationPresentation(data: unknown, foreground: boolean): 'screen' | 'notification' | 'dismiss' | null;
|
|
19
|
+
export declare function callingNotificationPresentation(data: unknown, foreground: boolean, group?: boolean): 'screen' | 'notification' | 'dismiss' | null;
|
|
@@ -6,7 +6,7 @@ export function createCallingNotificationRouter(options) {
|
|
|
6
6
|
const process = async (data, tapped) => {
|
|
7
7
|
if (disposed || options.recipientAccount(data) !== options.accountKey)
|
|
8
8
|
return false;
|
|
9
|
-
const event = parseCallingNotification(data);
|
|
9
|
+
const event = parseCallingNotification(data, options.group);
|
|
10
10
|
if (!event)
|
|
11
11
|
return false;
|
|
12
12
|
const ledger = await options.store.load(options.accountKey);
|
|
@@ -49,11 +49,11 @@ export function createCallingNotificationRouter(options) {
|
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
51
|
/** Provider-neutral presentation decision; leave unrelated notifications alone. */
|
|
52
|
-
export function callingNotificationPresentation(data, foreground) {
|
|
53
|
-
const event = parseCallingNotification(data);
|
|
52
|
+
export function callingNotificationPresentation(data, foreground, group = false) {
|
|
53
|
+
const event = parseCallingNotification(data, group);
|
|
54
54
|
if (!event)
|
|
55
55
|
return null;
|
|
56
|
-
if (event.event
|
|
56
|
+
if (event.event.endsWith('dismissed') || Date.parse(event.ring_expires_at) <= Date.now())
|
|
57
57
|
return 'dismiss';
|
|
58
58
|
return foreground ? 'screen' : 'notification';
|
|
59
59
|
}
|
package/dist/notifications.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { CallingController } from './types.js';
|
|
2
2
|
export interface CallingNotification {
|
|
3
|
-
|
|
3
|
+
kind?: 'voice' | 'video';
|
|
4
|
+
event: 'calling.incoming' | 'calling.dismissed' | 'calling.group_incoming' | 'calling.group_dismissed';
|
|
4
5
|
event_id: string;
|
|
5
6
|
call_id: string;
|
|
6
7
|
connection_id: string;
|
|
@@ -22,10 +23,11 @@ export declare function createCallingNotificationStore(storage: {
|
|
|
22
23
|
getItem(key: string): Promise<string | null>;
|
|
23
24
|
setItem(key: string, value: string): Promise<void>;
|
|
24
25
|
}, prefix?: string): NotificationStore;
|
|
25
|
-
export declare function parseCallingNotification(data: unknown): CallingNotification | null;
|
|
26
|
+
export declare function parseCallingNotification(data: unknown, group?: boolean): CallingNotification | null;
|
|
26
27
|
/** Host retains its push provider, credentials and notification handler. */
|
|
27
28
|
export declare function createCallingNotificationHandler(options: {
|
|
28
|
-
|
|
29
|
+
group?: boolean;
|
|
30
|
+
controller: Pick<CallingController, 'refresh' | 'openIncoming'>;
|
|
29
31
|
accountKey: string;
|
|
30
32
|
store: NotificationStore;
|
|
31
33
|
dismiss(callId: string): Promise<void>;
|