@robono/calling-react-native 0.2.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +108 -2
  3. package/RobonoCallingRuntime.podspec +1 -1
  4. package/SBOM.spdx.json +972 -156
  5. package/android/build.gradle +1 -1
  6. package/android/consumer-rules.pro +5 -0
  7. package/android/src/main/java/com/robono/calling/CallingRuntime.java +21 -0
  8. package/app.plugin.cjs +4 -2
  9. package/broadcast/SampleHandler.swift +92 -0
  10. package/dist/CallRecord.d.ts +19 -0
  11. package/dist/CallRecord.js +22 -0
  12. package/dist/appearance.d.ts +69 -4
  13. package/dist/appearance.js +70 -5
  14. package/dist/components.d.ts +135 -0
  15. package/dist/components.js +185 -0
  16. package/dist/controller.d.mts +1 -1
  17. package/dist/controller.mjs +59 -7
  18. package/dist/expo-notifications.d.ts +1 -1
  19. package/dist/expo-notifications.js +3 -3
  20. package/dist/group-phase.d.mts +4 -0
  21. package/dist/group-phase.mjs +26 -0
  22. package/dist/groups.d.ts +41 -0
  23. package/dist/groups.js +90 -0
  24. package/dist/history.d.ts +6 -15
  25. package/dist/history.js +3 -11
  26. package/dist/index.d.ts +4 -2
  27. package/dist/index.js +4 -2
  28. package/dist/native-video.d.ts +8 -0
  29. package/dist/native-video.js +10 -0
  30. package/dist/native.d.ts +2 -0
  31. package/dist/native.js +51 -2
  32. package/dist/notification-router.d.ts +2 -1
  33. package/dist/notification-router.js +4 -4
  34. package/dist/notifications.d.ts +5 -3
  35. package/dist/notifications.js +7 -5
  36. package/dist/runtime.d.ts +2 -1
  37. package/dist/runtime.js +2 -2
  38. package/dist/screens.d.ts +6 -54
  39. package/dist/screens.js +17 -42
  40. package/dist/types.d.ts +38 -1
  41. package/dist/versions.d.ts +2 -0
  42. package/dist/versions.js +3 -0
  43. package/dist/visual/RobonoIcon.d.ts +232 -0
  44. package/dist/visual/RobonoIcon.js +20 -0
  45. package/dist/visual/icon-nodes.d.ts +3 -0
  46. package/dist/visual/icon-nodes.js +2 -0
  47. package/dist/visual/icon-paths.d.ts +221 -0
  48. package/dist/visual/icon-paths.js +221 -0
  49. package/examples/CallingHost.tsx +27 -14
  50. package/examples/CustomCallingScreen.tsx +64 -0
  51. package/examples/ExpoGroupCallingHost.tsx +42 -0
  52. package/examples/GroupCallingHost.tsx +70 -0
  53. package/ios/RobonoCallingRuntime.m +24 -0
  54. package/licenses/robono-icons-lucide-license.txt +43 -0
  55. package/licenses/robono-icons-weather-attribution.txt +1 -0
  56. package/licenses/robono-icons-weather-license.txt +21 -0
  57. package/package.json +16 -4
  58. package/plugin/screensharing.cjs +39 -0
@@ -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,4 @@
1
- import { PermissionsAndroid, Platform } from 'react-native';
1
+ import { PermissionsAndroid, Platform, NativeModules } from 'react-native';
2
2
  import { mediaDevices, MediaStream, RTCPeerConnection } from 'react-native-webrtc';
3
3
  import InCallManager from 'react-native-incall-manager';
4
4
  import { createAudioPlayer, setAudioModeAsync } from 'expo-audio';
@@ -6,6 +6,8 @@ import { randomUUID } from 'expo-crypto';
6
6
  import { createCallAudio } from './audio.mjs';
7
7
  import { callingSounds } from './appearance.js';
8
8
  let audioOwner = null;
9
+ /** True while this adapter owns ringing or call audio. Use as the messaging audio session guard. */
10
+ export function isNativeCallAudioActive() { return audioOwner !== null; }
9
11
  /** Import this entry point only when choosing the supplied native audio adapter. */
10
12
  export function createNativeCallAdapters(options) {
11
13
  if (Platform.OS !== 'ios' && Platform.OS !== 'android')
@@ -134,6 +136,46 @@ export function createNativeCallAdapters(options) {
134
136
  createId: randomUUID,
135
137
  createPeerConnection: config => new RTCPeerConnection(config),
136
138
  createRemoteStream: track => new MediaStream([track]),
139
+ async getDisplayMedia(context) {
140
+ const current = () => !disposed && (!context || context.isCurrent());
141
+ if (!current())
142
+ throw Error('call_cancelled');
143
+ const native = NativeModules.RobonoCallingRuntime;
144
+ if (typeof native?.screenSharingPrepare !== 'function')
145
+ throw Error('screen_sharing_native_build_required');
146
+ await native.screenSharingPrepare();
147
+ if (!current())
148
+ throw Error('call_cancelled');
149
+ const stream = await mediaDevices.getDisplayMedia({});
150
+ if (Platform.OS === 'ios')
151
+ try {
152
+ await native.screenSharingStart();
153
+ const started = Date.now();
154
+ while (true) {
155
+ if (!current())
156
+ throw Error('call_cancelled');
157
+ const status = await native.screenSharingStatus();
158
+ if (status.active && status.at >= started - 1000)
159
+ break;
160
+ if (Date.now() - started > 30000)
161
+ throw Error('screen_capture_cancelled');
162
+ await new Promise(resolve => setTimeout(resolve, 250));
163
+ }
164
+ }
165
+ catch (e) {
166
+ stream.getTracks().forEach(t => t.stop());
167
+ throw e;
168
+ }
169
+ if (!current()) {
170
+ stream.getTracks().forEach(t => t.stop());
171
+ throw Error('call_cancelled');
172
+ }
173
+ return stream;
174
+ },
175
+ switchCamera(stream) {
176
+ const track = stream.getVideoTracks()[0];
177
+ track?._switchCamera();
178
+ },
137
179
  async getUserMedia(context) {
138
180
  const current = () => !disposed && (!context || context.isCurrent());
139
181
  if (!current())
@@ -145,6 +187,13 @@ export function createNativeCallAdapters(options) {
145
187
  if (result !== PermissionsAndroid.RESULTS.GRANTED)
146
188
  throw Error('microphone_permission_denied');
147
189
  }
190
+ if (Platform.OS === 'android' && context?.kind === 'video') {
191
+ const result = await PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.CAMERA);
192
+ if (!current())
193
+ throw Error('call_cancelled');
194
+ if (result !== PermissionsAndroid.RESULTS.GRANTED)
195
+ throw Error('camera_permission_denied');
196
+ }
148
197
  await audio.ready();
149
198
  if (!current())
150
199
  throw Error('call_cancelled');
@@ -155,7 +204,7 @@ export function createNativeCallAdapters(options) {
155
204
  }
156
205
  let stream;
157
206
  try {
158
- stream = await mediaDevices.getUserMedia({ audio: true, video: false });
207
+ 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
208
  }
160
209
  catch (error) {
161
210
  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 === 'calling.dismissed' || Date.parse(event.ring_expires_at) <= Date.now())
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
  }
@@ -1,6 +1,7 @@
1
1
  import type { CallingController } from './types.js';
2
2
  export interface CallingNotification {
3
- event: 'calling.incoming' | 'calling.dismissed';
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
- controller: CallingController;
29
+ group?: boolean;
30
+ controller: Pick<CallingController, 'refresh' | 'openIncoming'>;
29
31
  accountKey: string;
30
32
  store: NotificationStore;
31
33
  dismiss(callId: string): Promise<void>;
@@ -21,19 +21,21 @@ export function createCallingNotificationStore(storage, prefix = '@robono/callin
21
21
  save: (accountKey, ledger) => storage.setItem(prefix + encodeURIComponent(accountKey), JSON.stringify(ledger)),
22
22
  };
23
23
  }
24
- export function parseCallingNotification(data) {
24
+ export function parseCallingNotification(data, group = false) {
25
25
  if (!data || typeof data !== 'object')
26
26
  return null;
27
27
  const p = data;
28
- if (!['calling.incoming', 'calling.dismissed'].includes(String(p.event)))
28
+ if (p.kind !== undefined && !['voice', 'video'].includes(String(p.kind)))
29
+ return null;
30
+ if (!(group ? ['calling.group_incoming', 'calling.group_dismissed'] : ['calling.incoming', 'calling.dismissed']).includes(String(p.event)))
29
31
  return null;
30
32
  if (['call_id', 'event_id', 'connection_id'].some(key => typeof p[key] !== 'string' || !p[key] || p[key].length > 256))
31
33
  return null;
32
34
  if (typeof p.ring_expires_at !== 'string' || !Number.isFinite(Date.parse(p.ring_expires_at)))
33
35
  return null;
34
- if (p.sequence !== (p.event === 'calling.incoming' ? 1 : 2))
36
+ if (p.sequence !== (String(p.event).endsWith('incoming') ? 1 : 2))
35
37
  return null;
36
- return { event: p.event, event_id: p.event_id, call_id: p.call_id, connection_id: p.connection_id, ring_expires_at: p.ring_expires_at, sequence: p.sequence };
38
+ return { ...(p.kind ? { kind: p.kind } : {}), event: p.event, event_id: p.event_id, call_id: p.call_id, connection_id: p.connection_id, ring_expires_at: p.ring_expires_at, sequence: p.sequence };
37
39
  }
38
40
  /** Host retains its push provider, credentials and notification handler. */
39
41
  export function createCallingNotificationHandler(options) {
@@ -41,7 +43,7 @@ export function createCallingNotificationHandler(options) {
41
43
  const process = async (data, opened) => {
42
44
  if (disposed)
43
45
  return false;
44
- const event = parseCallingNotification(data);
46
+ const event = parseCallingNotification(data, options.group);
45
47
  if (!event)
46
48
  return false;
47
49
  const ledger = await options.store.load(options.accountKey);
package/dist/runtime.d.ts CHANGED
@@ -1,9 +1,10 @@
1
1
  import type { CallingController } from './types.js';
2
+ export type RuntimeController = Pick<CallingController, 'hangUp' | 'interrupt' | 'resume' | 'refresh' | 'getSnapshot' | 'setForeground'>;
2
3
  export interface CallRuntime {
3
4
  /** Start from the visible app, after microphone permission and before capture. */
4
5
  begin(): Promise<void>;
5
6
  end(): Promise<void>;
6
- attach(controller: CallingController): () => void;
7
+ attach(controller: RuntimeController): () => void;
7
8
  dispose(): Promise<void>;
8
9
  /** Audio cleanup deadline also advances on native call ticks in background. */
9
10
  schedule?(callback: () => void, delayMs: number): () => void;
package/dist/runtime.js CHANGED
@@ -91,7 +91,7 @@ export function createNativeCallRuntime(options) {
91
91
  // Native ticks don't depend on Android display-frame timers. Match the
92
92
  // engine's connection-loss deadline, including while a request is stuck.
93
93
  const state = controller.getSnapshot();
94
- const heldLease = state.localHeld && (state.call?.holdExpiresAt || 0) > now;
94
+ const heldLease = state.localHeld && (state.holdExpiresAt || state.call?.holdExpiresAt || 0) > now;
95
95
  if (now - lastBackgroundSuccess > 10000 && !heldLease) {
96
96
  endCall(!state.localHeld);
97
97
  return;
@@ -99,7 +99,7 @@ export function createNativeCallRuntime(options) {
99
99
  if (refreshing || now < nextRefresh)
100
100
  return;
101
101
  refreshing = true;
102
- nextRefresh = now + 1000;
102
+ nextRefresh = now + 3000;
103
103
  const currentToken = token;
104
104
  void controller.refresh().then(ok => {
105
105
  if (ok && token === currentToken)
package/dist/screens.d.ts CHANGED
@@ -1,58 +1,10 @@
1
1
  import React from 'react';
2
- import { type CallingAppearance } from './appearance.js';
3
- import type { CallingController, CallingState } from './types.js';
4
- export interface CallingTheme {
5
- background: string;
6
- foreground: string;
7
- secondary: string;
8
- control: string;
9
- accent: string;
10
- answer: string;
11
- end: string;
12
- }
13
- export interface CallingLabels {
14
- call: string;
15
- contact: string;
16
- incoming: string;
17
- outgoing: string;
18
- connecting: string;
19
- held: string;
20
- resume: string;
21
- resuming: string;
22
- resumeFailed: string;
23
- audioBusy: string;
24
- localHold: string;
25
- loading: string;
26
- answer: string;
27
- decline: string;
28
- mute: string;
29
- unmute: string;
30
- speaker: string;
31
- end: string;
32
- close: string;
33
- unavailable: string;
34
- failed: string;
35
- }
36
- export interface CallingScreenProps {
37
- state: CallingState;
38
- appearance?: CallingAppearance;
39
- onResume?(): void;
40
- onAnswer(): void;
41
- onHangUp(): void;
42
- onMute(value: boolean): void;
43
- onSpeaker(value: boolean): void;
44
- onClose(): void;
45
- theme?: Partial<CallingTheme>;
46
- labels?: Partial<CallingLabels>;
47
- formatError?: (code: string) => string;
48
- /** Insets from the host's safe-area provider, in logical pixels. */
49
- insets?: {
50
- top: number;
51
- bottom: number;
52
- };
53
- }
54
- export declare function CallingScreen(props: CallingScreenProps): React.JSX.Element | null;
55
- export declare function useCalling(controller: CallingController): CallingState;
2
+ import { type CallingScreenProps } from './components.js';
3
+ import type { CallingController } from './types.js';
4
+ export type { CallingScreenProps, CallingLabels, CallingTheme } from './components.js';
5
+ /** The ready-made screen is composed from the same public parts available to apps. */
6
+ export declare function CallingScreen(props: CallingScreenProps): React.JSX.Element;
7
+ export declare function useCalling(controller: CallingController): import("./types.js").CallingState;
56
8
  export interface CallingOverlayProps extends Omit<CallingScreenProps, 'state' | 'onResume' | 'onAnswer' | 'onHangUp' | 'onMute' | 'onSpeaker' | 'onClose'> {
57
9
  controller: CallingController;
58
10
  }
package/dist/screens.js CHANGED
@@ -1,37 +1,20 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useContext, useEffect, useState, useSyncExternalStore } from 'react';
3
- import { AppState, Image, Modal, Pressable, ScrollView, StatusBar, StyleSheet, Text, View } from 'react-native';
4
- import Svg, { Path } from 'react-native-svg';
5
- import { SafeAreaInsetsContext, SafeAreaProvider } from 'react-native-safe-area-context';
6
- import { callingColors, callingText, callingInk, callingIcons } from './appearance.js';
7
- const theme = callingColors;
8
- const labels = callingText;
9
- // Familiar handset, microphone and speaker silhouettes; never status checkmarks.
10
- function ControlIcon({ name, color, muted }) {
11
- return _jsxs(Svg, { width: 30, height: 30, viewBox: "0 0 24 24", accessible: false, children: [_jsx(Path, { d: callingIcons[name], fill: color }), muted && _jsx(Path, { d: "M3 2 22 21", stroke: color, strokeWidth: 2.5 })] });
12
- }
2
+ import { useEffect, useSyncExternalStore } from 'react';
3
+ import { AppState, Modal, StatusBar, useColorScheme } from 'react-native';
4
+ import { SafeAreaProvider } from 'react-native-safe-area-context';
5
+ import { callingInk, resolveCallingDesign } from './appearance.js';
6
+ import { CallingUIProvider, useCallingUI, CallingLayout, CallingIdentity, CallingControls, CallingVideo } from './components.js';
7
+ /** The ready-made screen is composed from the same public parts available to apps. */
13
8
  export function CallingScreen(props) {
14
- const safeArea = useContext(SafeAreaInsetsContext);
15
- const insets = props.insets || safeArea;
16
- const s = props.state, c = { ...theme, ...props.appearance?.theme, ...props.theme }, t = { ...labels, ...props.appearance?.labels, ...props.labels };
17
- const [clock, setClock] = useState(Date.now());
18
- useEffect(() => {
19
- if (s.phase !== 'connected')
20
- return;
21
- setClock(Date.now());
22
- const timer = setInterval(() => setClock(Date.now()), 1000);
23
- return () => clearInterval(timer);
24
- }, [s.phase, s.connectedAt]);
25
- if (s.phase === 'idle')
26
- return null;
27
- const seconds = s.connectedAt == null ? 0 : Math.max(0, Math.floor((clock - s.connectedAt) / 1000));
28
- const duration = `${Math.floor(seconds / 60)}:${String(seconds % 60).padStart(2, '0')}`;
29
- const title = s.contact?.name || t.contact;
30
- const error = s.phase === 'held' ? (s.resumeError ? props.formatError?.(s.resumeError) || (s.resumeError === 'audio_still_interrupted' ? t.audioBusy : t.resumeFailed) : null) : s.error ? props.formatError?.(s.error) || (s.error === 'call_unavailable' ? t.unavailable : t.failed) : null;
31
- const status = s.phase === 'connected' ? duration : s.phase === 'error' ? '' : t[s.phase];
32
- const control = (name, title, onPress, options = {}) => _jsxs(Pressable, { accessibilityRole: "button", accessibilityLabel: title, accessibilityState: { disabled: !!options.disabled, selected: !!options.selected }, disabled: options.disabled, onPress: onPress, hitSlop: 8, style: [styles.button, options.disabled && styles.disabled], children: [_jsx(View, { style: [styles.circle, { backgroundColor: options.color || (options.selected ? c.foreground : c.control) }], children: _jsx(ControlIcon, { name: name, muted: name === 'mute' && s.muted, color: options.color ? callingInk(options.color) : options.selected ? c.background : c.foreground }) }), _jsx(Text, { style: [styles.label, { color: c.foreground }], children: title })] }, name);
33
- return _jsxs(ScrollView, { style: { flex: 1, backgroundColor: c.background }, contentContainerStyle: [styles.screen, { paddingTop: Math.max(36, insets?.top || 0) + 32, paddingBottom: Math.max(24, insets?.bottom ?? 48) + 16 }], children: [_jsxs(View, { style: styles.identity, children: [(props.appearance?.logoUrl || props.appearance?.appName) && _jsxs(View, { style: { flexDirection: 'row', alignItems: 'center', gap: 8, marginBottom: 8 }, children: [props.appearance.logoUrl && _jsx(Image, { source: { uri: props.appearance.logoUrl }, style: { width: 28, height: 28, borderRadius: 6 }, resizeMode: "contain" }), _jsx(Text, { style: { color: c.secondary, fontSize: 14 }, children: props.appearance.appName })] }), s.contact?.avatarUri ? _jsx(Image, { source: { uri: s.contact.avatarUri }, style: styles.avatar, accessibilityIgnoresInvertColors: true })
34
- : _jsx(View, { style: [styles.avatar, { backgroundColor: c.control }], children: _jsx(Text, { style: [styles.initial, { color: c.accent }], children: title.trim().charAt(0).toUpperCase() }) }), _jsx(Text, { style: [styles.name, { color: c.foreground }], children: title }), _jsx(Text, { style: [styles.kind, { color: c.secondary }], children: t.call }), _jsx(Text, { style: [styles.status, { color: c.foreground }], accessibilityLiveRegion: s.phase === 'connected' ? 'none' : 'polite', children: status }), s.phase === 'held' && s.localHeld && _jsx(Text, { style: [styles.detail, { color: c.secondary }], children: t.localHold }), !!error && _jsx(Text, { accessibilityRole: "alert", style: [styles.detail, { color: c.foreground }], children: error })] }), _jsxs(View, { style: styles.controls, children: [s.phase === 'held' && s.localHeld && props.onResume && _jsx(Pressable, { accessibilityRole: "button", accessibilityState: { disabled: !!s.resumePending, busy: !!s.resumePending }, disabled: s.resumePending, onPress: props.onResume, style: [styles.close, { backgroundColor: c.control }, s.resumePending && styles.disabled], children: _jsx(Text, { style: [styles.label, { color: c.foreground }], children: s.resumePending ? t.resuming : t.resume }) }), ['outgoing', 'connecting', 'connected'].includes(s.phase) && _jsxs(View, { style: styles.row, children: [control('mute', s.muted ? t.unmute : t.mute, () => props.onMute(!s.muted), { disabled: !s.canMute, selected: s.muted }), control('speaker', t.speaker, () => props.onSpeaker(!s.speaker), { disabled: !s.canSpeaker, selected: s.speaker })] }), s.phase === 'error' || s.phase === 'loading' ? _jsx(Pressable, { accessibilityRole: "button", onPress: s.phase === 'loading' ? props.onHangUp : props.onClose, style: [styles.close, { backgroundColor: c.control }], children: _jsx(Text, { style: [styles.label, { color: c.foreground }], children: t.close }) }) : _jsxs(View, { style: styles.row, children: [control('end', s.phase === 'incoming' ? t.decline : t.end, props.onHangUp, { color: c.end }), s.phase === 'incoming' && control('answer', t.answer, props.onAnswer, { color: c.answer })] })] })] });
9
+ return _jsx(CallingUIProvider, { ...props, children: _jsx(CallingScreenContent, {}) });
10
+ }
11
+ function CallingScreenContent() {
12
+ const { components } = useCallingUI();
13
+ const Layout = components.Layout || CallingLayout;
14
+ const Identity = components.Identity || CallingIdentity;
15
+ const Controls = components.Controls || CallingControls;
16
+ const Video = components.Video || CallingVideo;
17
+ return _jsxs(Layout, { children: [_jsx(Identity, {}), _jsx(Video, {}), _jsx(Controls, {})] });
35
18
  }
36
19
  export function useCalling(controller) {
37
20
  return useSyncExternalStore(controller.subscribe, controller.getSnapshot, controller.getSnapshot);
@@ -39,6 +22,7 @@ export function useCalling(controller) {
39
22
  /** Mount only when you choose Robono's interface. No global navigation changes. */
40
23
  export function CallingOverlay({ controller, ...props }) {
41
24
  const state = useCalling(controller);
25
+ const design = resolveCallingDesign(props.appearance, useColorScheme());
42
26
  useEffect(() => { controller.reportComponents?.(['screens']); }, [controller]);
43
27
  useEffect(() => {
44
28
  controller.setForeground(AppState.currentState === 'active');
@@ -46,14 +30,5 @@ export function CallingOverlay({ controller, ...props }) {
46
30
  return () => sub.remove();
47
31
  }, [controller]);
48
32
  const active = state.phase !== 'idle';
49
- return _jsx(Modal, { visible: active, presentationStyle: "fullScreen", animationType: "none", onRequestClose: () => { void controller.hangUp().catch(() => { }); }, children: active && _jsxs(SafeAreaProvider, { children: [_jsx(StatusBar, { barStyle: callingInk(props.theme?.background || props.appearance?.theme.background || theme.background) === '#000000' ? 'dark-content' : 'light-content' }), _jsx(CallingScreen, { ...props, state: state, onResume: () => { void controller.resume().catch(() => { }); }, onAnswer: () => { void controller.answer().catch(() => { }); }, onHangUp: () => { void controller.hangUp().catch(() => { }); }, onMute: value => controller.mute(value), onSpeaker: value => controller.setSpeaker(value), onClose: () => controller.dismissError() })] }) });
33
+ return _jsx(Modal, { visible: active, presentationStyle: "fullScreen", animationType: "none", onRequestClose: () => { void controller.hangUp().catch(() => { }); }, children: active && _jsxs(SafeAreaProvider, { children: [_jsx(StatusBar, { barStyle: callingInk(props.theme?.background || design.colors.background) === '#000000' ? 'dark-content' : 'light-content' }), _jsx(CallingScreen, { ...props, state: state, onResume: () => { void controller.resume().catch(() => { }); }, onAnswer: () => { void controller.answer().catch(() => { }); }, onHangUp: () => { void controller.hangUp().catch(() => { }); }, onMute: value => controller.mute(value), onScreenShare: controller.startScreenSharing ? () => { void (state.screenSharing ? controller.stopScreenSharing?.() : controller.startScreenSharing?.())?.catch(() => { }); } : undefined, onCamera: controller.setCamera ? value => controller.setCamera?.(value) : undefined, onSwitchCamera: controller.switchCamera ? () => { void controller.switchCamera?.(); } : undefined, onSpeaker: value => controller.setSpeaker(value), onClose: () => controller.dismissError() })] }) });
50
34
  }
51
- const styles = StyleSheet.create({
52
- screen: { flexGrow: 1, paddingHorizontal: 24, justifyContent: 'space-between', gap: 40 },
53
- identity: { alignItems: 'center', gap: 14 }, avatar: { height: 104, width: 104, borderRadius: 52, alignItems: 'center', justifyContent: 'center', marginBottom: 16 },
54
- initial: { fontSize: 44, fontWeight: '600' }, name: { fontSize: 28, fontWeight: '600', textAlign: 'center' },
55
- kind: { fontSize: 16 }, status: { fontSize: 21, marginTop: 8, textAlign: 'center' }, detail: { fontSize: 16, textAlign: 'center' },
56
- controls: { gap: 30, alignItems: 'center' }, row: { flexDirection: 'row', justifyContent: 'center', gap: 48, flexWrap: 'wrap' },
57
- button: { alignItems: 'center', gap: 10, minWidth: 80, maxWidth: 140 }, circle: { height: 72, width: 72, borderRadius: 36, alignItems: 'center', justifyContent: 'center' },
58
- label: { fontSize: 17, textAlign: 'center' }, disabled: { opacity: 0.4 }, close: { paddingVertical: 16, paddingHorizontal: 32, borderRadius: 28 },
59
- });
package/dist/types.d.ts CHANGED
@@ -7,6 +7,27 @@ export interface Contact {
7
7
  export interface CallingState {
8
8
  resumePending?: boolean;
9
9
  resumeError?: string | null;
10
+ group?: boolean;
11
+ groupMembers?: Array<{
12
+ id: number;
13
+ name: string;
14
+ avatarUri?: string;
15
+ state: string;
16
+ held?: boolean;
17
+ local?: boolean;
18
+ sharing?: boolean;
19
+ stream?: MediaStream | null;
20
+ }>;
21
+ screenSharing?: boolean;
22
+ screenSharePending?: boolean;
23
+ canScreenShare?: boolean;
24
+ displayStream?: MediaStream | null;
25
+ remoteScreenSharing?: boolean;
26
+ kind?: 'voice' | 'video';
27
+ cameraEnabled?: boolean;
28
+ canCamera?: boolean;
29
+ localStream?: MediaStream | null;
30
+ remoteStream?: MediaStream | null;
10
31
  phase: Phase;
11
32
  call: Call | null;
12
33
  contact: Contact | null;
@@ -17,6 +38,7 @@ export interface CallingState {
17
38
  connectedAt: number | null;
18
39
  error: string | null;
19
40
  localHeld?: boolean;
41
+ holdExpiresAt?: number | null;
20
42
  }
21
43
  export interface CallAudio {
22
44
  robonoAdapter?: boolean;
@@ -33,6 +55,10 @@ export interface CallAudio {
33
55
  }
34
56
  export type MediaAdapter = Required<Pick<ConstructorParameters<typeof RobonoCallingClient>[0], 'getUserMedia' | 'createPeerConnection' | 'createRemoteStream' | 'createId'>> & {
35
57
  robonoAdapter?: boolean;
58
+ getDisplayMedia?: (context?: {
59
+ isCurrent: () => boolean;
60
+ }) => Promise<MediaStream>;
61
+ switchCamera?(stream: MediaStream): Promise<void> | void;
36
62
  };
37
63
  export interface CallingOptions {
38
64
  appearanceRevision?: number;
@@ -42,6 +68,11 @@ export interface CallingOptions {
42
68
  forceRelay?: boolean;
43
69
  resolveContact?: (connectionId: string) => Contact | null;
44
70
  onError?: (error: Error) => void;
71
+ /** Optional navigation to the existing chat to offer a separately recorded message. */
72
+ onUnansweredCall?: (call: {
73
+ id: string;
74
+ connectionId: string;
75
+ }) => void;
45
76
  }
46
77
  export interface CallingController {
47
78
  reportComponents?(components: string[]): void;
@@ -50,7 +81,9 @@ export interface CallingController {
50
81
  subscribe(listener: () => void): () => void;
51
82
  listen(): Promise<void>;
52
83
  refresh(): Promise<boolean>;
53
- call(connectionId: string, contact?: Contact): Promise<void>;
84
+ call(connectionId: string, contact?: Contact, options?: {
85
+ kind?: 'voice' | 'video';
86
+ }): Promise<void>;
54
87
  answer(): Promise<void>;
55
88
  /** Suppress the end cue when the OS currently owns audio. */
56
89
  hangUp(options?: {
@@ -58,6 +91,10 @@ export interface CallingController {
58
91
  }): Promise<void>;
59
92
  interrupt(): Promise<void>;
60
93
  resume(): Promise<void>;
94
+ startScreenSharing?(): Promise<void>;
95
+ stopScreenSharing?(): Promise<void>;
96
+ setCamera?(enabled: boolean): void;
97
+ switchCamera?(): Promise<void>;
61
98
  mute(value: boolean): void;
62
99
  setSpeaker(value: boolean): void;
63
100
  setForeground(value: boolean): void;
@@ -0,0 +1,2 @@
1
+ export declare const mobileVersion = "0.3.0";
2
+ export declare const engineVersion = "0.2.0";
@@ -0,0 +1,3 @@
1
+ // Generated from the package manifests by build.mjs.
2
+ export const mobileVersion = "0.3.0";
3
+ export const engineVersion = "0.2.0";