@robono/messaging-react-native 0.26.2 → 0.27.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 (75) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +18 -1
  3. package/SBOM.spdx.json +1698 -618
  4. package/app.plugin.cjs +4 -0
  5. package/dist/bubble-design.d.ts +1 -0
  6. package/dist/bubble-design.js +1 -0
  7. package/dist/call-message-decoration.d.ts +15 -0
  8. package/dist/call-message-decoration.js +23 -0
  9. package/dist/calling-timeline.d.ts +40 -0
  10. package/dist/calling-timeline.js +79 -0
  11. package/dist/calling.d.ts +4 -1
  12. package/dist/calling.js +8 -5
  13. package/dist/expo-connected-calling.d.ts +4 -0
  14. package/dist/expo-connected-calling.js +3 -1
  15. package/dist/expo-messenger.d.ts +10 -0
  16. package/dist/expo-messenger.js +7 -1
  17. package/dist/expo-reviews.js +1 -1
  18. package/dist/expo-screen.d.ts +32 -0
  19. package/dist/expo-screen.js +93 -49
  20. package/dist/expo-thumbnails.js +2 -2
  21. package/dist/expo-video-orientation.d.ts +7 -0
  22. package/dist/expo-video-orientation.js +14 -0
  23. package/dist/expo-video-thumbnail.d.ts +6 -0
  24. package/dist/expo-video-thumbnail.js +30 -0
  25. package/dist/expo-voicemail-recorder.d.ts +18 -0
  26. package/dist/expo-voicemail-recorder.js +214 -0
  27. package/dist/expo-voicemail-storage.d.ts +10 -0
  28. package/dist/expo-voicemail-storage.js +81 -0
  29. package/dist/expo-voicemail-video.d.ts +15 -0
  30. package/dist/expo-voicemail-video.js +44 -0
  31. package/dist/expo-voicemail.d.ts +34 -0
  32. package/dist/expo-voicemail.js +110 -0
  33. package/dist/expo.d.ts +3 -0
  34. package/dist/expo.js +3 -0
  35. package/dist/header-action-group.d.ts +11 -0
  36. package/dist/header-action-group.js +7 -0
  37. package/dist/header-calls.js +2 -1
  38. package/dist/history-anchor.d.ts +29 -0
  39. package/dist/history-anchor.js +74 -0
  40. package/dist/history-follow.d.ts +18 -0
  41. package/dist/history-follow.js +35 -0
  42. package/dist/index.d.ts +14 -1
  43. package/dist/index.js +105 -63
  44. package/dist/message-time.d.ts +7 -0
  45. package/dist/message-time.js +17 -0
  46. package/dist/messenger-video-view.d.ts +4 -1
  47. package/dist/messenger-video-view.js +15 -4
  48. package/dist/recording-notice.d.ts +5 -0
  49. package/dist/recording-notice.js +13 -0
  50. package/dist/use-quote-gesture.d.ts +1 -0
  51. package/dist/use-quote-gesture.js +1 -0
  52. package/dist/video-message-badge.d.ts +7 -0
  53. package/dist/video-message-badge.js +8 -0
  54. package/dist/video-orientation.d.ts +13 -0
  55. package/dist/video-orientation.js +58 -0
  56. package/dist/voice-composer.d.ts +3 -1
  57. package/dist/voice-composer.js +7 -6
  58. package/dist/voicemail-flow.d.ts +60 -0
  59. package/dist/voicemail-flow.js +156 -0
  60. package/dist/voicemail-media.d.ts +19 -0
  61. package/dist/voicemail-media.js +45 -0
  62. package/dist/voicemail-message.d.ts +41 -0
  63. package/dist/voicemail-message.js +48 -0
  64. package/dist/voicemail-prompts.d.ts +4 -0
  65. package/dist/voicemail-prompts.js +3 -0
  66. package/dist/voicemail-recording.d.ts +15 -0
  67. package/dist/voicemail-recording.js +46 -0
  68. package/dist/voicemail-session.d.ts +19 -0
  69. package/dist/voicemail-session.js +48 -0
  70. package/dist/voicemail.d.ts +179 -0
  71. package/dist/voicemail.js +234 -0
  72. package/package.json +9 -5
  73. package/plugin/prepare-native.cjs +1 -0
  74. package/plugin/video-display-mirror.cjs +66 -0
  75. package/setup.plugin.cjs +1 -0
@@ -0,0 +1,15 @@
1
+ import type { VoicemailAPI, VoicemailRecord } from './voicemail.js';
2
+ /** Bind to the host's ordinary downloaded-media store to share its retention and
3
+ * account cleanup. URLs are transport credentials, never the stored recording. */
4
+ export interface VoicemailRecordingStorage {
5
+ read(message: VoicemailRecord): Promise<string | null>;
6
+ write(message: VoicemailRecord, url: string): Promise<string>;
7
+ release?(uri: string): void;
8
+ /** Resolve only after hashing and syncing the complete original to durable storage. */
9
+ commitDurable?(message: VoicemailRecord, uri: string): Promise<{
10
+ sha256: string;
11
+ byteSize: number;
12
+ }>;
13
+ }
14
+ export declare function voicemailRecordingKey(message: VoicemailRecord): string;
15
+ export declare function loadVoicemailRecording(client: VoicemailAPI, message: VoicemailRecord, storage: VoicemailRecordingStorage): Promise<string>;
@@ -0,0 +1,46 @@
1
+ export function voicemailRecordingKey(message) {
2
+ const owner = message.direction === 'sent' ? message.sender : message.recipient;
3
+ return [owner.appId, owner.userId, message.connectionId, message.id].map(encodeURIComponent).join('/');
4
+ }
5
+ const pending = new WeakMap();
6
+ export async function loadVoicemailRecording(client, message, storage) {
7
+ if (message.deletedAt)
8
+ throw Error('This recording was deleted.');
9
+ const key = voicemailRecordingKey(message);
10
+ let requests = pending.get(storage);
11
+ if (!requests) {
12
+ requests = new Map();
13
+ pending.set(storage, requests);
14
+ }
15
+ const existing = requests.get(key);
16
+ if (existing) {
17
+ await existing;
18
+ const local = await storage.read(message);
19
+ if (local)
20
+ return local;
21
+ throw Error('The downloaded recording is unavailable.');
22
+ }
23
+ const work = (async () => {
24
+ let local = await storage.read(message);
25
+ if (!local) {
26
+ const access = await client.recording(message.id);
27
+ local = await storage.write(message, access.url);
28
+ }
29
+ if (message.storageMode === 'device' && storage.commitDurable && client.confirmDurable) {
30
+ const uri = local;
31
+ // Playback does not wait for a delivery receipt; receipt failures retry on reopen.
32
+ void storage.commitDurable(message, uri).then(proof => client.confirmDurable(message, proof)).catch(() => { });
33
+ }
34
+ if (message.direction !== 'sent' && !message.deliveredAt && client.markDelivered)
35
+ void client.markDelivered(message.id).catch(() => { });
36
+ return local;
37
+ })();
38
+ requests.set(key, work);
39
+ try {
40
+ return await work;
41
+ }
42
+ finally {
43
+ if (requests.get(key) === work)
44
+ requests.delete(key);
45
+ }
46
+ }
@@ -0,0 +1,19 @@
1
+ import { VoicemailClient, type VoicemailCallState } from '@robono/calling/voicemail';
2
+ /** Connect voicemail to any existing calling client. The supplied transport must
3
+ * already authenticate the account; no messaging permission or chat is required. */
4
+ export declare function useCallingVoicemail({ request, call, createId, retainSession, historyStorage }: {
5
+ request: ConstructorParameters<typeof VoicemailClient>[0]['request'] | null;
6
+ call: VoicemailCallState | null;
7
+ createId: () => string;
8
+ retainSession?: () => () => void;
9
+ historyStorage?: ConstructorParameters<typeof VoicemailClient>[0]['historyStorage'];
10
+ }): {
11
+ client: VoicemailClient | null;
12
+ offer: {
13
+ id: string;
14
+ connectionId: string;
15
+ kind: "voice" | "video";
16
+ } | null;
17
+ revision: number;
18
+ dismiss: () => void;
19
+ };
@@ -0,0 +1,48 @@
1
+ import { useEffect, useMemo, useRef, useState } from 'react';
2
+ import { VoicemailClient, createVoicemailCallObserver } from '@robono/calling/voicemail';
3
+ /** Connect voicemail to any existing calling client. The supplied transport must
4
+ * already authenticate the account; no messaging permission or chat is required. */
5
+ export function useCallingVoicemail({ request, call, createId, retainSession, historyStorage }) {
6
+ // Local history belongs to the signed-in account's storage, not to a live
7
+ // signaling session. Keep it visible while admission reconnects or is offline.
8
+ const transport = useRef({ request, historyStorage });
9
+ transport.current = { request, historyStorage };
10
+ const directRequest = historyStorage ? null : request;
11
+ const client = useMemo(() => {
12
+ if (!historyStorage)
13
+ return directRequest ? new VoicemailClient({ request: directRequest, createId }) : null;
14
+ const owner = historyStorage;
15
+ return new VoicemailClient({ createId, historyStorage, request: (operation, body) => {
16
+ const current = transport.current;
17
+ if (current.historyStorage !== owner || !current.request)
18
+ return Promise.reject(Error('Calling is temporarily unavailable.'));
19
+ return current.request(operation, body);
20
+ } });
21
+ }, [directRequest, createId, historyStorage]);
22
+ useEffect(() => { if (request && client)
23
+ void client.list({ includeSent: true, limit: 100 }).catch(() => { }); }, [request, client]);
24
+ useEffect(() => { if (client)
25
+ void client.restoreHistory(); }, [client]);
26
+ const [offer, setOffer] = useState(null), [revision, setRevision] = useState(0);
27
+ const current = useRef(call);
28
+ current.current = call;
29
+ const observer = useMemo(() => createVoicemailCallObserver(current.current), [client]);
30
+ const owner = useRef(client);
31
+ owner.current = client;
32
+ const release = useRef(undefined);
33
+ useEffect(() => { owner.current = client; setOffer(null); return () => { owner.current = null; release.current?.(); release.current = undefined; }; }, [client]);
34
+ useEffect(() => {
35
+ const next = observer(call);
36
+ if (!client || !next)
37
+ return;
38
+ release.current?.();
39
+ release.current = retainSession?.();
40
+ void client.options(next.id).then(() => { if (owner.current === client)
41
+ setOffer(next); }).catch(error => { if (owner.current === client) {
42
+ release.current?.();
43
+ release.current = undefined;
44
+ } if (typeof __DEV__ !== 'undefined' && __DEV__)
45
+ console.warn('[voicemail-offer]', error?.code ?? error?.message ?? 'unavailable'); });
46
+ }, [client, observer, call, retainSession]);
47
+ return { client, offer, revision, dismiss: () => { release.current?.(); release.current = undefined; setOffer(null); setRevision(n => n + 1); } };
48
+ }
@@ -0,0 +1,179 @@
1
+ import React from 'react';
2
+ export declare const voicemailVideoWidth = 160;
3
+ export interface VoicemailAppearance {
4
+ background: string;
5
+ foreground: string;
6
+ accent: string;
7
+ }
8
+ export interface VoicemailRecord {
9
+ waveform?: number[];
10
+ deliveredAt?: number | null;
11
+ direction?: 'received' | 'sent';
12
+ storageMode?: 'device' | 'retained';
13
+ localDurable?: boolean;
14
+ mediaSha256?: string;
15
+ serverPurgedAt?: number | null;
16
+ id: string;
17
+ callId: string;
18
+ connectionId: string;
19
+ kind: 'voice' | 'video';
20
+ createdAt: number;
21
+ durationMs: number;
22
+ sender: {
23
+ appId: string;
24
+ userId: string;
25
+ };
26
+ recipient: {
27
+ appId: string;
28
+ userId: string;
29
+ };
30
+ byteSize: number;
31
+ mimeType: string;
32
+ expiresAt: number;
33
+ readAt: number | null;
34
+ deletedAt: number | null;
35
+ }
36
+ export interface VoicemailAPI {
37
+ cachedList?(input?: {
38
+ connectionId?: string;
39
+ conversationId?: string;
40
+ includeSent?: boolean;
41
+ limit?: number;
42
+ }): VoicemailRecord[];
43
+ restoreHistory?(): Promise<void>;
44
+ subscribe?(listener: () => void): () => void;
45
+ options(callId: string): Promise<{
46
+ kind: 'voice' | 'video';
47
+ maxDurationMs: number;
48
+ maxByteSize: number;
49
+ retentionDays: number;
50
+ }>;
51
+ prepareSend(callId: string, assetId: string, waveform?: number[]): {
52
+ callId: string;
53
+ assetId: string;
54
+ requestId: string;
55
+ waveform?: number[];
56
+ };
57
+ send(input: {
58
+ callId: string;
59
+ assetId: string;
60
+ requestId: string;
61
+ waveform?: number[];
62
+ }): Promise<{
63
+ message: VoicemailRecord | null;
64
+ replayed: boolean;
65
+ }>;
66
+ list(input?: {
67
+ limit?: number;
68
+ cursor?: string;
69
+ connectionId?: string;
70
+ conversationId?: string;
71
+ includeSent?: boolean;
72
+ }): Promise<{
73
+ messages: VoicemailRecord[];
74
+ nextCursor: string | null;
75
+ }>;
76
+ markDelivered?(id: string): Promise<VoicemailRecord>;
77
+ markRead(id: string): Promise<VoicemailRecord>;
78
+ delete(id: string): Promise<{
79
+ deleted: true;
80
+ }>;
81
+ recording(id: string): Promise<{
82
+ url: string;
83
+ expiresAt: number;
84
+ }>;
85
+ confirmDurable?(message: VoicemailRecord, proof: {
86
+ sha256: string;
87
+ byteSize: number;
88
+ }): Promise<unknown>;
89
+ }
90
+ export interface VoicemailDraft {
91
+ /** Upload only when Send is chosen. Repeated calls reuse the verified asset. */
92
+ upload(): Promise<{
93
+ assetId: string;
94
+ }>;
95
+ /** Release the draft's owned local resources; never delete an accepted recording. */
96
+ release(): Promise<void>;
97
+ }
98
+ /** Shared recorder review, independent of MessagingProvider and message permissions.
99
+ * Capture and preview use the platform adapter; neither is automatic. */
100
+ export declare function VoicemailComposer({ client, callId, record, renderPreview, onCancel, onSent, appearance }: {
101
+ client: VoicemailAPI;
102
+ callId: string;
103
+ appearance?: VoicemailAppearance;
104
+ record(options: {
105
+ kind: 'voice' | 'video';
106
+ maxDurationMs: number;
107
+ maxByteSize: number;
108
+ }): Promise<VoicemailDraft | null>;
109
+ renderPreview(draft: VoicemailDraft): React.ReactNode;
110
+ onCancel: () => void;
111
+ onSent: (message: VoicemailRecord | null) => void;
112
+ }): React.JSX.Element;
113
+ /** Presentation is optional. Custom hosts can use VoicemailClient directly. */
114
+ export declare function VoicemailInbox({ client, onOpen, name }: {
115
+ client: VoicemailAPI;
116
+ onOpen: (message: VoicemailRecord) => void;
117
+ name: (sender: VoicemailRecord['sender']) => string;
118
+ }): React.JSX.Element;
119
+ export interface VoicemailUploadAPI extends VoicemailAPI {
120
+ prepareUpload(input: {
121
+ callId: string;
122
+ uploadId: string;
123
+ kind: 'voice' | 'video';
124
+ file: {
125
+ mimeType: string;
126
+ fileName: string;
127
+ byteSize: number;
128
+ };
129
+ }, context?: {
130
+ signal?: AbortSignal;
131
+ }): Promise<{
132
+ url: string;
133
+ headers?: Record<string, string>;
134
+ } | {
135
+ media: {
136
+ assetId: string;
137
+ mimeType: string;
138
+ byteSize: number;
139
+ durationMs: number;
140
+ };
141
+ }>;
142
+ completeUpload(input: {
143
+ callId: string;
144
+ uploadId: string;
145
+ }, context?: {
146
+ signal?: AbortSignal;
147
+ }): Promise<{
148
+ media: {
149
+ assetId: string;
150
+ mimeType: string;
151
+ byteSize: number;
152
+ durationMs: number;
153
+ };
154
+ }>;
155
+ discardUpload(input: {
156
+ callId: string;
157
+ uploadId: string;
158
+ }, context?: {
159
+ signal?: AbortSignal;
160
+ }): Promise<{
161
+ discarded: true;
162
+ }>;
163
+ }
164
+ /** Same records in a standalone mailbox or a conversation section; no copied
165
+ * message, second upload or second delivery charge is created for presentation. */
166
+ export declare function VoicemailMailbox({ client, name, conversationId, connectionId, revision, renderRecording, appearance }: {
167
+ client: VoicemailAPI;
168
+ name: (sender: VoicemailRecord['sender']) => string;
169
+ conversationId?: string;
170
+ connectionId?: string;
171
+ revision?: number;
172
+ renderRecording: (message: VoicemailRecord, access: {
173
+ url: string;
174
+ expiresAt: number;
175
+ }, onRead: () => void) => React.ReactNode;
176
+ appearance?: VoicemailAppearance;
177
+ }): React.JSX.Element | null;
178
+ /** Authorized recording history; each recording has its own chat row and message ID. */
179
+ export declare function useConversationVoicemail(client: VoicemailAPI | null, connectionId: string, revision?: number): VoicemailRecord[];
@@ -0,0 +1,234 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useRobonoLocale } from './localization.js';
3
+ import { useEffect, useRef, useState } from 'react';
4
+ import { ActivityIndicator, Pressable, Text, View } from 'react-native';
5
+ export const voicemailVideoWidth = 160;
6
+ /** Shared recorder review, independent of MessagingProvider and message permissions.
7
+ * Capture and preview use the platform adapter; neither is automatic. */
8
+ export function VoicemailComposer({ client, callId, record, renderPreview, onCancel, onSent, appearance }) {
9
+ const { text: uiText } = useRobonoLocale();
10
+ const colors = appearance ?? { background: '#fff', foreground: '#151515', accent: '#2463eb' };
11
+ const [option, setOption] = useState(null);
12
+ const [draft, setDraft] = useState(null), [busy, setBusy] = useState(false), [error, setError] = useState('');
13
+ const [revision, setRevision] = useState(0), epoch = useRef(0), working = useRef(false), owned = useRef(null);
14
+ const pending = useRef(null);
15
+ useEffect(() => {
16
+ const generation = ++epoch.current;
17
+ working.current = false;
18
+ setBusy(false);
19
+ setOption(null);
20
+ setDraft(null);
21
+ pending.current = null;
22
+ setError('');
23
+ void client.options(callId).then(value => { if (epoch.current === generation)
24
+ setOption(value); }).catch(() => { if (epoch.current === generation)
25
+ setError('Voicemail is unavailable. Try again.'); });
26
+ return () => { epoch.current++; const old = owned.current; owned.current = null; void old?.release().catch(() => { }); };
27
+ }, [client, callId, revision]);
28
+ async function capture() {
29
+ if (working.current || !option)
30
+ return;
31
+ working.current = true;
32
+ setBusy(true);
33
+ setError('');
34
+ const generation = epoch.current;
35
+ try {
36
+ const current = await client.options(callId);
37
+ if (epoch.current !== generation)
38
+ return;
39
+ const next = await record(current);
40
+ if (!next)
41
+ return;
42
+ if (epoch.current !== generation) {
43
+ await next.release();
44
+ return;
45
+ }
46
+ const previous = owned.current;
47
+ owned.current = next;
48
+ pending.current = null;
49
+ setDraft(next);
50
+ void previous?.release().catch(() => { });
51
+ }
52
+ catch {
53
+ if (epoch.current === generation)
54
+ setError('The recording could not be prepared. Try again.');
55
+ }
56
+ finally {
57
+ if (epoch.current === generation) {
58
+ working.current = false;
59
+ setBusy(false);
60
+ }
61
+ }
62
+ }
63
+ async function send() {
64
+ if (working.current || !draft)
65
+ return;
66
+ working.current = true;
67
+ setBusy(true);
68
+ setError('');
69
+ const generation = epoch.current;
70
+ try {
71
+ if (!pending.current) {
72
+ await client.options(callId);
73
+ if (epoch.current !== generation)
74
+ return;
75
+ const media = await draft.upload();
76
+ if (epoch.current !== generation)
77
+ return;
78
+ pending.current = client.prepareSend(callId, media.assetId);
79
+ }
80
+ const result = await client.send(pending.current);
81
+ if (epoch.current !== generation)
82
+ return;
83
+ const old = owned.current;
84
+ owned.current = null;
85
+ pending.current = null;
86
+ setDraft(null);
87
+ void old?.release().catch(() => { });
88
+ onSent(result.message);
89
+ }
90
+ catch (error) {
91
+ if (epoch.current === generation) {
92
+ const status = error?.status;
93
+ if (status && [400, 403, 404, 409, 410, 422].includes(status))
94
+ pending.current = null;
95
+ setError('Your recording was kept. Try sending again.');
96
+ }
97
+ }
98
+ finally {
99
+ if (epoch.current === generation) {
100
+ working.current = false;
101
+ setBusy(false);
102
+ }
103
+ }
104
+ }
105
+ const loadingOptions = !option && !error;
106
+ const button = (label, action, primary = false) => _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText(label), accessibilityState: { disabled: busy || primary && !option, busy: primary && (busy || loadingOptions) }, disabled: busy || primary && !option, onPress: action, style: { minHeight: 44, minWidth: 100, paddingHorizontal: 14, alignItems: 'center', justifyContent: 'center', borderRadius: 22, backgroundColor: primary ? colors.accent : colors.background }, children: primary && (busy || loadingOptions) ? _jsx(ActivityIndicator, { color: "#fff" }) : _jsx(Text, { style: { color: primary ? '#fff' : colors.foreground }, children: uiText(label) }) });
107
+ return _jsxs(View, { testID: "voicemail-composer", style: { padding: 16, gap: 12, backgroundColor: colors.background }, children: [_jsx(Text, { accessibilityRole: "header", style: { fontSize: 18, fontWeight: '600', color: colors.foreground }, children: uiText('Leave a message') }), _jsx(View, { style: { minHeight: 60 }, children: draft ? renderPreview(draft) : _jsx(Text, { style: { color: colors.foreground }, children: option ? uiText(`Record a ${option.kind} message. Review it before sending.`) : '' }) }), _jsxs(View, { style: { flexDirection: 'row', flexWrap: 'wrap', gap: 8 }, children: [button('Cancel', onCancel), draft && !pending.current && button('Record again', () => void capture()), button(draft ? 'Send message' : option ? `Record ${option.kind} message` : 'Record message', () => void (draft ? send() : capture()), true), !option && error && button('Try again', () => setRevision(n => n + 1))] }), !!error && _jsx(Text, { accessibilityRole: "alert", children: uiText(error) })] });
108
+ }
109
+ /** Presentation is optional. Custom hosts can use VoicemailClient directly. */
110
+ export function VoicemailInbox({ client, onOpen, name }) {
111
+ const { text: uiText } = useRobonoLocale();
112
+ const [messages, setMessages] = useState([]), [cursor, setCursor] = useState(null), [busy, setBusy] = useState(false), [error, setError] = useState('');
113
+ const epoch = useRef(0), working = useRef(false);
114
+ async function load(next) {
115
+ if (working.current)
116
+ return;
117
+ working.current = true;
118
+ setBusy(true);
119
+ setError('');
120
+ const generation = epoch.current;
121
+ try {
122
+ const page = await client.list({ limit: 25, ...(next ? { cursor: next } : {}) });
123
+ if (epoch.current !== generation)
124
+ return;
125
+ setMessages(old => next ? [...new Map([...old, ...page.messages].map(m => [m.id, m])).values()] : page.messages);
126
+ setCursor(page.nextCursor);
127
+ }
128
+ catch {
129
+ if (epoch.current === generation)
130
+ setError('Messages could not load. Try again.');
131
+ }
132
+ finally {
133
+ if (epoch.current === generation) {
134
+ working.current = false;
135
+ setBusy(false);
136
+ }
137
+ }
138
+ }
139
+ useEffect(() => { epoch.current++; working.current = false; setBusy(false); setMessages([]); setCursor(null); void load(); return () => { epoch.current++; }; }, [client]);
140
+ return _jsxs(View, { testID: "voicemail-inbox", style: { padding: 16, gap: 8 }, children: [_jsx(Text, { accessibilityRole: "header", style: { fontSize: 20, fontWeight: '600' }, children: uiText('Voicemail') }), messages.map(message => _jsxs(Pressable, { accessibilityRole: "button", onPress: () => onOpen(message), style: { minHeight: 64, justifyContent: 'center', padding: 12, borderBottomWidth: 1, borderBottomColor: '#ddd' }, children: [_jsx(Text, { style: { fontWeight: message.readAt ? '400' : '700' }, children: name(message.sender) }), _jsxs(Text, { children: [uiText(message.kind === 'voice' ? 'Voice message' : 'Video message'), " \u00B7 ", Math.floor(Math.ceil(message.durationMs / 1000) / 60), ":", String(Math.ceil(message.durationMs / 1000) % 60).padStart(2, '0')] })] }, message.id)), _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: cursor ? 'Load more voicemail' : 'Refresh voicemail', accessibilityState: { busy, disabled: busy }, disabled: busy, onPress: () => void load(cursor ?? undefined), style: { height: 44, alignItems: 'center', justifyContent: 'center' }, children: busy ? _jsx(ActivityIndicator, {}) : _jsx(Text, { children: cursor ? 'Load more' : 'Refresh' }) }), !busy && !messages.length && !error && _jsx(Text, { children: uiText('No voicemail.') }), !!error && _jsx(Text, { accessibilityRole: "alert", children: uiText(error) })] });
141
+ }
142
+ /** Same records in a standalone mailbox or a conversation section; no copied
143
+ * message, second upload or second delivery charge is created for presentation. */
144
+ export function VoicemailMailbox({ client, name, conversationId, connectionId, revision = 0, renderRecording, appearance }) {
145
+ const { text: uiText } = useRobonoLocale();
146
+ const [rows, setRows] = useState([]), [cursor, setCursor] = useState(null), [busy, setBusy] = useState(false), [error, setError] = useState('');
147
+ const [opened, setOpened] = useState(null);
148
+ const epoch = useRef(0), working = useRef(false), playback = useRef(0);
149
+ const colors = appearance ?? { background: '#fff', foreground: '#151515', accent: '#2463eb' };
150
+ async function load(next, refresh = false) {
151
+ if (working.current)
152
+ return;
153
+ working.current = true;
154
+ setBusy(true);
155
+ setError('');
156
+ const generation = epoch.current;
157
+ try {
158
+ const page = await client.list({ limit: 25, ...(connectionId ? { connectionId, includeSent: true } : conversationId ? { conversationId, includeSent: true } : {}), ...(next ? { cursor: next } : {}) });
159
+ if (generation !== epoch.current)
160
+ return;
161
+ setRows(old => next || refresh ? [...new Map([...old, ...page.messages].map(m => [m.id, m])).values()].filter(m => m.expiresAt > Date.now()).sort((a, b) => b.createdAt - a.createdAt || b.id.localeCompare(a.id)) : page.messages);
162
+ if (!refresh)
163
+ setCursor(page.nextCursor);
164
+ }
165
+ catch {
166
+ if (generation === epoch.current)
167
+ setError('Voicemail could not load. Try again.');
168
+ }
169
+ finally {
170
+ if (generation === epoch.current) {
171
+ working.current = false;
172
+ setBusy(false);
173
+ }
174
+ }
175
+ }
176
+ useEffect(() => { epoch.current++; working.current = false; setRows([]); setOpened(null); setCursor(null); void load(); const timer = setInterval(() => void load(undefined, true), 30000); return () => { epoch.current++; clearInterval(timer); }; }, [client, conversationId, connectionId, revision]);
177
+ async function action(work) {
178
+ if (working.current)
179
+ return;
180
+ working.current = true;
181
+ setBusy(true);
182
+ setError('');
183
+ const generation = epoch.current;
184
+ try {
185
+ await work();
186
+ }
187
+ catch {
188
+ if (generation === epoch.current)
189
+ setError('The message could not be updated. Try again.');
190
+ }
191
+ finally {
192
+ if (generation === epoch.current) {
193
+ working.current = false;
194
+ setBusy(false);
195
+ }
196
+ }
197
+ }
198
+ const read = (message) => { if (message.direction === 'sent' || message.readAt)
199
+ return; const generation = epoch.current; void action(async () => { const updated = await client.markRead(message.id); if (generation === epoch.current)
200
+ setRows(old => old.map(m => m.id === updated.id ? { ...m, ...updated } : m)); }); };
201
+ const button = (label, run) => _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText(label), accessibilityState: { busy, disabled: busy }, disabled: busy, onPress: run, style: { minHeight: 44, paddingHorizontal: 12, justifyContent: 'center' }, children: _jsx(Text, { style: { color: colors.accent }, children: uiText(label) }) });
202
+ if ((conversationId || connectionId) && !rows.length && !error)
203
+ return null;
204
+ return _jsxs(View, { style: { backgroundColor: colors.background, padding: 12, gap: 8 }, testID: "voicemail-mailbox", children: [_jsx(Text, { accessibilityRole: "header", style: { fontWeight: '600', fontSize: 18, color: colors.foreground }, children: uiText('Voicemail') }), rows.map(message => _jsxs(View, { style: { paddingVertical: 8, borderBottomWidth: 1, borderBottomColor: colors.accent }, children: [_jsxs(Text, { style: { color: colors.foreground, fontWeight: message.readAt ? '400' : '700' }, children: [message.direction === 'sent' ? uiText('You') : name(message.sender), " \u00B7 ", uiText(message.kind === 'voice' ? 'Voice message' : 'Video message')] }), _jsxs(Text, { style: { color: colors.foreground }, children: [new Date(message.createdAt).toLocaleString(), " \u00B7 ", Math.floor(Math.ceil(message.durationMs / 1000) / 60), ":", String(Math.ceil(message.durationMs / 1000) % 60).padStart(2, '0')] }), _jsxs(View, { style: { flexDirection: 'row', flexWrap: 'wrap' }, children: [button('Play', () => { const generation = epoch.current; void action(async () => { const access = await client.recording(message.id); if (generation === epoch.current)
205
+ setOpened({ message, access, nonce: ++playback.current }); }); }), message.direction !== 'sent' && !message.readAt && button('Mark read', () => read(message)), message.direction !== 'sent' && button('Delete', () => { const generation = epoch.current; void action(async () => { await client.delete(message.id); if (generation !== epoch.current)
206
+ return; setRows(old => old.filter(m => m.id !== message.id)); setOpened(old => old?.message.id === message.id ? null : old); }); })] }), opened?.message.id === message.id && _jsx(View, { children: renderRecording(message, opened.access, () => read(message)) }, opened.nonce)] }, message.id)), _jsx(View, { style: { height: 44, justifyContent: 'center' }, children: busy ? _jsx(ActivityIndicator, { accessibilityLabel: "Loading voicemail" }) : button(cursor ? 'Load more' : 'Refresh', () => void load(cursor ?? undefined)) }), !busy && !rows.length && !error && _jsx(Text, { style: { color: colors.foreground }, children: uiText('No voicemail.') }), !!error && _jsx(Text, { accessibilityRole: "alert", style: { color: colors.foreground }, children: uiText(error) })] });
207
+ }
208
+ /** Authorized recording history; each recording has its own chat row and message ID. */
209
+ export function useConversationVoicemail(client, connectionId, revision = 0) {
210
+ const query = { connectionId, includeSent: true, limit: 100 };
211
+ const [state, setState] = useState({ owner: client, key: connectionId, messages: client?.cachedList?.(query) ?? [] });
212
+ useEffect(() => {
213
+ let alive = true, working = false;
214
+ const cached = () => { if (alive && client?.cachedList)
215
+ setState({ owner: client, key: connectionId, messages: client.cachedList(query) }); };
216
+ const load = async () => { if (working || !client)
217
+ return; working = true; try {
218
+ const result = await client.list(query);
219
+ if (alive)
220
+ setState({ owner: client, key: connectionId, messages: client.cachedList?.(query) ?? result.messages });
221
+ }
222
+ catch { /* Local history remains available during refresh. */ }
223
+ finally {
224
+ working = false;
225
+ } };
226
+ cached();
227
+ void client?.restoreHistory?.().then(cached);
228
+ const stop = client?.subscribe?.(cached);
229
+ void load();
230
+ const timer = setInterval(() => void load(), 10000);
231
+ return () => { alive = false; clearInterval(timer); stop?.(); };
232
+ }, [client, connectionId, revision]);
233
+ return state.owner === client && state.key === connectionId ? state.messages : client?.cachedList?.(query) ?? [];
234
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@robono/messaging-react-native",
3
- "version": "0.26.2",
3
+ "version": "0.27.0",
4
4
  "type": "module",
5
5
  "sideEffects": [
6
6
  "./dist/expo-notification-cleanup.js"
@@ -73,7 +73,7 @@
73
73
  "prepack": "npm run build && node ../../scripts/generate-sdk-file-sbom.mjs"
74
74
  },
75
75
  "peerDependencies": {
76
- "@robono/messaging": "^0.20.3",
76
+ "@robono/messaging": "^0.21.0",
77
77
  "react": ">=18.2 <20",
78
78
  "react-native": ">=0.76 <1",
79
79
  "expo-audio": ">=55 <57",
@@ -85,7 +85,7 @@
85
85
  "expo-crypto": ">=55 <57",
86
86
  "react-native-safe-area-context": ">=5 <6",
87
87
  "react-native-svg": ">=15 <16",
88
- "@robono/calling-react-native": "^0.11.3",
88
+ "@robono/calling-react-native": "^0.12.0",
89
89
  "expo-clipboard": ">=8 <57",
90
90
  "expo-image-manipulator": ">=14 <57",
91
91
  "expo-video-thumbnails": ">=14 <57",
@@ -98,13 +98,14 @@
98
98
  "expo-constants": ">=55 <57",
99
99
  "@robono/location": "^0.4.1",
100
100
  "expo-haptics": ">=55 <57",
101
- "@robono/calling": "^0.7.0",
101
+ "@robono/calling": "^0.8.0",
102
102
  "expo-media-library": ">=55 <57",
103
103
  "expo-task-manager": ">=55.0.0 <57.0.0",
104
104
  "expo-application": ">=55 <57",
105
105
  "react-native-passkey": "^3.6.2",
106
106
  "expo-background-task": ">=55 <57",
107
- "expo-network": ">=55 <57"
107
+ "expo-network": ">=55 <57",
108
+ "expo-camera": ">=55 <57"
108
109
  },
109
110
  "license": "SEE LICENSE IN LICENSE",
110
111
  "peerDependenciesMeta": {
@@ -173,6 +174,9 @@
173
174
  },
174
175
  "expo-network": {
175
176
  "optional": true
177
+ },
178
+ "expo-camera": {
179
+ "optional": true
176
180
  }
177
181
  },
178
182
  "author": {
@@ -6,6 +6,7 @@ const path = require('node:path');
6
6
  function prepareNativeDependencies(projectRoot, options = {}) {
7
7
  const root = path.resolve(projectRoot);
8
8
  require('./preserve-call-audio.cjs').install(root);
9
+ require('./video-display-mirror.cjs').install(root);
9
10
  if (options.backupBackgroundTasks) require('./backup-expiration.cjs').install(root);
10
11
  }
11
12