@robono/messaging-react-native 0.26.3 → 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 (74) hide show
  1. package/README.md +18 -1
  2. package/SBOM.spdx.json +1696 -616
  3. package/app.plugin.cjs +4 -0
  4. package/dist/bubble-design.d.ts +1 -0
  5. package/dist/bubble-design.js +1 -0
  6. package/dist/call-message-decoration.d.ts +15 -0
  7. package/dist/call-message-decoration.js +23 -0
  8. package/dist/calling-timeline.d.ts +40 -0
  9. package/dist/calling-timeline.js +79 -0
  10. package/dist/calling.d.ts +4 -1
  11. package/dist/calling.js +8 -5
  12. package/dist/expo-connected-calling.d.ts +4 -0
  13. package/dist/expo-connected-calling.js +3 -1
  14. package/dist/expo-messenger.d.ts +10 -0
  15. package/dist/expo-messenger.js +7 -1
  16. package/dist/expo-reviews.js +1 -1
  17. package/dist/expo-screen.d.ts +32 -0
  18. package/dist/expo-screen.js +93 -49
  19. package/dist/expo-thumbnails.js +2 -2
  20. package/dist/expo-video-orientation.d.ts +7 -0
  21. package/dist/expo-video-orientation.js +14 -0
  22. package/dist/expo-video-thumbnail.d.ts +6 -0
  23. package/dist/expo-video-thumbnail.js +30 -0
  24. package/dist/expo-voicemail-recorder.d.ts +18 -0
  25. package/dist/expo-voicemail-recorder.js +214 -0
  26. package/dist/expo-voicemail-storage.d.ts +10 -0
  27. package/dist/expo-voicemail-storage.js +81 -0
  28. package/dist/expo-voicemail-video.d.ts +15 -0
  29. package/dist/expo-voicemail-video.js +44 -0
  30. package/dist/expo-voicemail.d.ts +34 -0
  31. package/dist/expo-voicemail.js +110 -0
  32. package/dist/expo.d.ts +3 -0
  33. package/dist/expo.js +3 -0
  34. package/dist/header-action-group.d.ts +11 -0
  35. package/dist/header-action-group.js +7 -0
  36. package/dist/header-calls.js +2 -1
  37. package/dist/history-anchor.d.ts +29 -0
  38. package/dist/history-anchor.js +74 -0
  39. package/dist/history-follow.d.ts +18 -0
  40. package/dist/history-follow.js +35 -0
  41. package/dist/index.d.ts +14 -1
  42. package/dist/index.js +94 -74
  43. package/dist/message-time.d.ts +7 -0
  44. package/dist/message-time.js +17 -0
  45. package/dist/messenger-video-view.d.ts +4 -1
  46. package/dist/messenger-video-view.js +15 -4
  47. package/dist/recording-notice.d.ts +5 -0
  48. package/dist/recording-notice.js +13 -0
  49. package/dist/use-quote-gesture.d.ts +1 -0
  50. package/dist/use-quote-gesture.js +1 -0
  51. package/dist/video-message-badge.d.ts +7 -0
  52. package/dist/video-message-badge.js +8 -0
  53. package/dist/video-orientation.d.ts +13 -0
  54. package/dist/video-orientation.js +58 -0
  55. package/dist/voice-composer.d.ts +3 -1
  56. package/dist/voice-composer.js +7 -6
  57. package/dist/voicemail-flow.d.ts +60 -0
  58. package/dist/voicemail-flow.js +156 -0
  59. package/dist/voicemail-media.d.ts +19 -0
  60. package/dist/voicemail-media.js +45 -0
  61. package/dist/voicemail-message.d.ts +41 -0
  62. package/dist/voicemail-message.js +48 -0
  63. package/dist/voicemail-prompts.d.ts +4 -0
  64. package/dist/voicemail-prompts.js +3 -0
  65. package/dist/voicemail-recording.d.ts +15 -0
  66. package/dist/voicemail-recording.js +46 -0
  67. package/dist/voicemail-session.d.ts +19 -0
  68. package/dist/voicemail-session.js +48 -0
  69. package/dist/voicemail.d.ts +179 -0
  70. package/dist/voicemail.js +234 -0
  71. package/package.json +9 -5
  72. package/plugin/prepare-native.cjs +1 -0
  73. package/plugin/video-display-mirror.cjs +66 -0
  74. package/setup.plugin.cjs +1 -0
@@ -0,0 +1,81 @@
1
+ import * as FS from 'expo-file-system/legacy';
2
+ import * as Crypto from 'expo-crypto';
3
+ import { NativeModules } from 'react-native';
4
+ import { createNativeHistoryStore } from './native-history.js';
5
+ import { voicemailRecordingKey } from './voicemail-recording.js';
6
+ // Bounded SDK fallback. Hosts can supply their normal durable media store instead.
7
+ const root = () => { if (!FS.cacheDirectory)
8
+ throw Error('Device media storage is unavailable.'); return FS.cacheDirectory + 'messaging-voicemail/'; };
9
+ const path = async (message) => root() + await Crypto.digestStringAsync(Crypto.CryptoDigestAlgorithm.SHA256, voicemailRecordingKey(message)) + '.mp4';
10
+ export const expoVoicemailRecordingStorage = {
11
+ async read(message) { const uri = await path(message), info = await FS.getInfoAsync(uri); return info.exists && !info.isDirectory && info.size === message.byteSize ? uri : null; },
12
+ async write(message, url) {
13
+ const uri = await path(message);
14
+ await FS.makeDirectoryAsync(root(), { intermediates: true });
15
+ let bytes = 0;
16
+ for (const name of await FS.readDirectoryAsync(root())) {
17
+ const info = await FS.getInfoAsync(root() + name);
18
+ if (info.exists && !info.isDirectory)
19
+ bytes += info.size;
20
+ }
21
+ if (bytes + message.byteSize > 256 * 1024 * 1024)
22
+ throw Error('The voicemail cache is full. Free some downloaded media and try again.');
23
+ const part = uri + '.' + Crypto.randomUUID() + '.part';
24
+ try {
25
+ const result = await FS.downloadAsync(url, part);
26
+ const info = await FS.getInfoAsync(part);
27
+ if (result.status !== 200 || !info.exists || info.isDirectory || info.size !== message.byteSize)
28
+ throw Error('The recording did not finish downloading.');
29
+ await FS.moveAsync({ from: part, to: uri });
30
+ return uri;
31
+ }
32
+ finally {
33
+ await FS.deleteAsync(part, { idempotent: true }).catch(() => { });
34
+ }
35
+ }
36
+ };
37
+ /** Device-history originals use the same hashing/fsync native store as ordinary
38
+ * attachments. The normal media store still supplies retention-aware play copies. */
39
+ export function withExpoDurableVoicemailStorage(namespace, base) {
40
+ const context = async (message) => {
41
+ const owner = message.direction === 'sent' ? message.sender : message.recipient;
42
+ const scope = await Crypto.digestStringAsync(Crypto.CryptoDigestAlgorithm.SHA256, JSON.stringify([namespace, 'voicemail', owner.appId, owner.userId]));
43
+ const store = createNativeHistoryStore(commands => NativeModules.RobonoHistoryStore.execute(scope, JSON.stringify(commands)));
44
+ return { scope, generation: await store.generation() };
45
+ };
46
+ return { ...base,
47
+ async read(message) {
48
+ const local = await base.read(message);
49
+ if (local)
50
+ return local;
51
+ if (message.storageMode !== 'device' || !message.mediaSha256 || !NativeModules.RobonoHistoryStore?.copyOriginal)
52
+ return null;
53
+ const { scope, generation } = await context(message);
54
+ if (!await NativeModules.RobonoHistoryStore.verifyOriginal(scope, message.mediaSha256, message.byteSize))
55
+ return null;
56
+ const uri = await path(message);
57
+ await FS.makeDirectoryAsync(root(), { intermediates: true });
58
+ await NativeModules.RobonoHistoryStore.copyOriginal(scope, message.mediaSha256, message.byteSize, generation, uri);
59
+ return uri;
60
+ },
61
+ async commitDurable(message, uri) {
62
+ if (!message.mediaSha256 || !NativeModules.RobonoHistoryStore?.saveOriginalGuarded)
63
+ throw Error('Durable recording storage is unavailable.');
64
+ const { scope, generation } = await context(message);
65
+ await NativeModules.RobonoHistoryStore.saveOriginalGuarded(scope, uri, message.mediaSha256, message.byteSize, generation);
66
+ if (!await NativeModules.RobonoHistoryStore.verifyOriginal(scope, message.mediaSha256, message.byteSize))
67
+ throw Error('The saved recording could not be verified.');
68
+ return { sha256: message.mediaSha256, byteSize: message.byteSize };
69
+ },
70
+ };
71
+ }
72
+ /** Explicit account removal, never triggered by viewing or server delivery cleanup. */
73
+ export async function clearExpoDurableVoicemailAccount(namespace, owner) {
74
+ if (!NativeModules.RobonoHistoryStore?.executeAndClearOriginals)
75
+ return;
76
+ const scope = await Crypto.digestStringAsync(Crypto.CryptoDigestAlgorithm.SHA256, JSON.stringify([namespace, 'voicemail', owner.appId, owner.userId]));
77
+ const store = createNativeHistoryStore(commands => NativeModules.RobonoHistoryStore.execute(scope, JSON.stringify(commands)), {
78
+ clearAll: commands => NativeModules.RobonoHistoryStore.executeAndClearOriginals(scope, JSON.stringify(commands)),
79
+ });
80
+ await store.clear();
81
+ }
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ import type { MessagingAppearance } from '@robono/messaging';
3
+ import type { LocalMessagingMedia } from './media-controller.js';
4
+ import type { MessagingAudioSession } from './expo-media.js';
5
+ export declare function ExpoVoicemailVideo({ file, audio, design, onPlayed, onLongPress, onDimensions, onOpen, onForward, onDelete }: {
6
+ onOpen?: (poster?: string) => void;
7
+ onForward?: () => void;
8
+ onDelete?: () => void;
9
+ file: LocalMessagingMedia;
10
+ audio: MessagingAudioSession;
11
+ design: MessagingAppearance;
12
+ onPlayed: () => void;
13
+ onLongPress?: () => void;
14
+ onDimensions: (width: number, height: number) => void;
15
+ }): React.JSX.Element;
@@ -0,0 +1,44 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { createMessagingVideoThumbnail } from './expo-video-thumbnail.js';
3
+ import { useEffect, useState } from 'react';
4
+ import * as Sharing from 'expo-sharing';
5
+ import * as MediaLibrary from 'expo-media-library';
6
+ import { RecordingNotice } from './recording-notice.js';
7
+ import { Image, Modal, Pressable, View } from 'react-native';
8
+ import { SafeAreaProvider, SafeAreaView } from 'react-native-safe-area-context';
9
+ import * as Images from 'expo-image-manipulator';
10
+ import * as FS from 'expo-file-system/legacy';
11
+ import { MessagingPreviewCache } from './preview-cache.js';
12
+ import { MediaViewer } from './media-ui.js';
13
+ import { VideoPlayer } from './expo-screen.js';
14
+ import { MessageIcon } from './icons.js';
15
+ // One thumbnail decoder at a time; no native video players in the chat list.
16
+ const previews = new MessagingPreviewCache({ concurrency: 1, maximum: 40, ttlMs: 3600000, timeoutMs: 10000 });
17
+ export function ExpoVoicemailVideo({ file, audio, design, onPlayed, onLongPress, onDimensions, onOpen, onForward, onDelete }) {
18
+ const [error, setError] = useState('');
19
+ const perform = (action) => { void action().catch(() => setError('Could not complete that action. Try again.')); };
20
+ const [open, setOpen] = useState(false), [expanded, setExpanded] = useState(false), [poster, setPoster] = useState(() => previews.peek(file.uri)?.uri);
21
+ useEffect(() => {
22
+ let alive = true;
23
+ void previews.get(file.uri, async (signal) => {
24
+ let frame, image;
25
+ try {
26
+ frame = (await createMessagingVideoThumbnail(file.uri, { time: 0, quality: .5 })).uri;
27
+ if (signal.aborted)
28
+ return {};
29
+ const result = await Images.manipulateAsync(frame, [{ resize: { width: 320 } }], { compress: .6, format: Images.SaveFormat.JPEG, base64: true });
30
+ image = result.uri;
31
+ return result.base64 ? { uri: 'data:image/jpeg;base64,' + result.base64 } : {};
32
+ }
33
+ finally {
34
+ for (const uri of [frame, image])
35
+ if (uri && FS.cacheDirectory && uri.startsWith(FS.cacheDirectory))
36
+ await FS.deleteAsync(uri, { idempotent: true }).catch(() => { });
37
+ }
38
+ }).then(value => { if (alive)
39
+ setPoster(value.uri); });
40
+ return () => { alive = false; };
41
+ }, [file.uri]);
42
+ return _jsxs(_Fragment, { children: [_jsxs(Pressable, { accessibilityRole: "button", accessibilityLabel: "Play video", onLongPress: onLongPress, onPress: () => onOpen ? onOpen(poster) : setOpen(true), style: { flex: 1, backgroundColor: '#111', alignItems: 'center', justifyContent: 'center' }, children: [poster && _jsx(Image, { source: { uri: poster }, resizeMode: "cover", onLoad: e => onDimensions(e.nativeEvent.source.width, e.nativeEvent.source.height), style: { position: 'absolute', width: '100%', height: '100%' } }), _jsx(View, { style: { width: 48, height: 48, borderRadius: 24, backgroundColor: '#0007', alignItems: 'center', justifyContent: 'center' }, children: _jsx(MessageIcon, { name: "play", size: 28, color: "#fff" }) })] }), _jsx(Modal, { visible: open, transparent: true, animationType: "none", onRequestClose: () => setOpen(false), children: _jsx(SafeAreaProvider, { children: _jsxs(SafeAreaView, { style: { flex: 1, backgroundColor: '#000' }, edges: expanded ? [] : ['top', 'bottom', 'left', 'right'], children: [_jsx(MediaViewer, { showDelete: design.mediaViewer?.delete !== false, showForward: design.mediaViewer?.forward !== false, onForward: design.mediaViewer?.forward !== false && onForward ? () => { setOpen(false); onForward(); } : undefined, onDelete: design.mediaViewer?.delete !== false && onDelete ? () => { setOpen(false); onDelete(); } : undefined, onDownload: design.showDownloadButton === true ? () => perform(async () => { if (!(await MediaLibrary.requestPermissionsAsync()).granted)
43
+ throw Error('Permission required'); await MediaLibrary.saveToLibraryAsync(file.uri); }) : undefined, onShare: design.mediaViewer?.share !== false ? () => perform(() => Sharing.shareAsync(file.uri, { mimeType: file.mimeType })) : undefined, kind: "video", title: "Video", uri: file.uri, previewUri: poster, expanded: expanded, onExpandedChange: setExpanded, onClose: () => setOpen(false), children: open && _jsx(VideoPlayer, { file: { ...file, autoPlay: true }, posterUri: poster, audio: audio, design: design, onPlayed: onPlayed }) }), _jsx(RecordingNotice, { message: error })] }) }) })] });
44
+ }
@@ -0,0 +1,34 @@
1
+ import { type VoicemailRecordingStorage } from './voicemail-recording.js';
2
+ import { type VoicemailMessageActions } from './voicemail-message.js';
3
+ import React from 'react';
4
+ import { type MessagingAppearance } from '@robono/messaging';
5
+ import { VoicemailMailbox, type VoicemailUploadAPI, type VoicemailRecord } from './voicemail.js';
6
+ import { type MessagingAudioSession } from './expo-media.js';
7
+ import { type MessagingMediaStorage } from './media-controller.js';
8
+ /** Standalone native capture/review using the same media engine as Messenger.
9
+ * Storage must be a calling-authorized voicemail adapter, not messaging storage. */
10
+ export declare function ExpoVoicemailComposer({ client, callId, storage: suppliedStorage, audioSession, appearance, onCancel, onSent, registerHangUp, initialKind, onSendMessage }: {
11
+ onSendMessage?: (file: import('./media-controller.js').LocalMessagingMedia, kind: 'voice' | 'video') => Promise<void>;
12
+ initialKind?: 'voice' | 'video';
13
+ client: VoicemailUploadAPI;
14
+ callId: string;
15
+ storage?: MessagingMediaStorage;
16
+ audioSession?: MessagingAudioSession;
17
+ appearance?: MessagingAppearance;
18
+ onCancel: () => void;
19
+ onSent: (message: VoicemailRecord | null) => void;
20
+ registerHangUp?: (handler: () => void) => () => void;
21
+ }): React.JSX.Element;
22
+ /** Capture-only private transfer adapter. No ordinary messaging endpoint is used. */
23
+ export declare function createExpoVoicemailStorage(client: VoicemailUploadAPI, callId: string): MessagingMediaStorage;
24
+ export declare function ExpoVoicemailMailbox(props: Omit<React.ComponentProps<typeof VoicemailMailbox>, 'renderRecording'>): React.JSX.Element;
25
+ /** Recording content shared by independent chat messages and standalone inboxes. */
26
+ export declare function ExpoVoicemailCallAttachment({ client, message, appearance, recordingStorage }: {
27
+ client: VoicemailUploadAPI;
28
+ message: VoicemailRecord;
29
+ appearance?: MessagingAppearance;
30
+ recordingStorage?: VoicemailRecordingStorage;
31
+ }): React.JSX.Element;
32
+ export declare function ExpoVoicemailMessage({ actions, ...props }: React.ComponentProps<typeof ExpoVoicemailCallAttachment> & {
33
+ actions?: VoicemailMessageActions;
34
+ }): React.JSX.Element;
@@ -0,0 +1,110 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { VoicePlayback } from './media-ui.js';
3
+ import { ExpoVoicemailVideo } from './expo-voicemail-video.js';
4
+ import { VideoMessageBadge } from './video-message-badge.js';
5
+ import { loadVoicemailRecording } from './voicemail-recording.js';
6
+ import { expoVoicemailRecordingStorage } from './expo-voicemail-storage.js';
7
+ import { Text } from './typography.js';
8
+ import { bubbleCorners } from './bubble-design.js';
9
+ import { useMessagingAppearance } from './appearance-context.js';
10
+ import { VoicemailMessageActionContext, VoicemailMessageTitle, VoicemailTimestamp, VoicemailMessageMenu, VoicemailMessageBubble, voicemailVideoSize } from './voicemail-message.js';
11
+ import { StreamRecovery } from './media-readiness.js';
12
+ import { ExpoVoicemailRecorder } from './expo-voicemail-recorder.js';
13
+ import { useEffect, useMemo, useRef, useState, useContext } from 'react';
14
+ import { ActivityIndicator, Pressable, View } from 'react-native';
15
+ import { randomUUID } from 'expo-crypto';
16
+ import { defaultMessagingSettings } from '@robono/messaging';
17
+ import { VoicemailMailbox } from './voicemail.js';
18
+ import { VoicePlayer, MessagingMediaOverlay } from './expo-screen.js';
19
+ import { createExpoMessagingDevice, createExpoMessagingAudioSession } from './expo-media.js';
20
+ import * as FS from 'expo-file-system/legacy';
21
+ import { MessagingMediaController } from './media-controller.js';
22
+ /** Standalone native capture/review using the same media engine as Messenger.
23
+ * Storage must be a calling-authorized voicemail adapter, not messaging storage. */
24
+ export function ExpoVoicemailComposer({ client, callId, storage: suppliedStorage, audioSession, appearance, onCancel, onSent, registerHangUp, initialKind, onSendMessage }) {
25
+ const storage = useMemo(() => suppliedStorage ?? createExpoVoicemailStorage(client, callId), [suppliedStorage, client, callId]);
26
+ return _jsx(ExpoVoicemailRecorder, { client: client, callId: callId, storage: storage, audioSession: audioSession, appearance: appearance, onCancel: onCancel, onSent: onSent, registerHangUp: registerHangUp, initialKind: initialKind, onSendMessage: onSendMessage });
27
+ }
28
+ function checkVoicemailAbort(signal) { if (signal.aborted)
29
+ throw Object.assign(Error('The recording was cancelled.'), { name: 'AbortError' }); }
30
+ /** Capture-only private transfer adapter. No ordinary messaging endpoint is used. */
31
+ export function createExpoVoicemailStorage(client, callId) {
32
+ return {
33
+ async upload(file, context) {
34
+ checkVoicemailAbort(context.signal);
35
+ if (context.conversationId !== callId || !['voice', 'video'].includes(context.kind))
36
+ throw Error('This recording belongs to another call.');
37
+ const plan = await client.prepareUpload({ callId, uploadId: context.uploadId, kind: context.kind, file: { mimeType: file.mimeType, fileName: file.fileName, byteSize: file.byteSize } }, { signal: context.signal });
38
+ checkVoicemailAbort(context.signal);
39
+ if ('media' in plan)
40
+ return { ...plan.media, fileName: file.fileName };
41
+ const url = new URL(plan.url);
42
+ if (url.protocol !== 'https:' || url.username || url.password)
43
+ throw Error('The private upload could not be prepared.');
44
+ const task = FS.createUploadTask(url.href, file.uri, { httpMethod: 'PUT', uploadType: FS.FileSystemUploadType.BINARY_CONTENT, headers: plan.headers ?? {}, sessionType: FS.FileSystemSessionType.FOREGROUND }, progress => context.onProgress(progress.totalBytesExpectedToSend > 0 ? progress.totalBytesSent / progress.totalBytesExpectedToSend : 0));
45
+ const cancel = () => { void task.cancelAsync().catch(() => { }); };
46
+ context.signal.addEventListener('abort', cancel, { once: true });
47
+ try {
48
+ checkVoicemailAbort(context.signal);
49
+ const response = await task.uploadAsync();
50
+ checkVoicemailAbort(context.signal);
51
+ if (!response || response.status !== 412 && (response.status < 200 || response.status >= 300))
52
+ throw Error('The recording could not be uploaded. Try sending again.');
53
+ const result = await client.completeUpload({ callId, uploadId: context.uploadId }, { signal: context.signal });
54
+ checkVoicemailAbort(context.signal);
55
+ return { ...result.media, fileName: file.fileName };
56
+ }
57
+ finally {
58
+ context.signal.removeEventListener('abort', cancel);
59
+ }
60
+ },
61
+ async discard(uploadId) { await client.discardUpload({ callId, uploadId }); },
62
+ async download() { throw Error('Open received voicemail through its authorized recording access.'); },
63
+ };
64
+ }
65
+ function ExpoVoicemailPlayback({ message, access, onRead }) {
66
+ const [error, setError] = useState(false);
67
+ const [controller, setController] = useState(null), read = useRef(onRead);
68
+ read.current = onRead;
69
+ const audio = useMemo(() => createExpoMessagingAudioSession(), []), design = useMemo(() => defaultMessagingSettings('Voicemail').appearance, []);
70
+ useEffect(() => {
71
+ let closed = false;
72
+ setError(false);
73
+ const player = new MessagingMediaController({ device: createExpoMessagingDevice(audio), storage: { upload: async () => { throw Error('Playback only'); }, download: async () => { throw Error('Refresh the recording to play again.'); }, discard: async () => { } }, createId: randomUUID, getConversationId: () => message.callId, getSettings: () => defaultMessagingSettings('Voicemail') });
74
+ setController(player);
75
+ void player.previewLocal({ uri: access.url, stream: {}, autoPlay: true, fileName: message.kind === 'voice' ? 'Voicemail.mp4' : 'Voicemail video.mp4', mimeType: message.mimeType, byteSize: message.byteSize, durationMs: message.durationMs }, message.kind).then(() => { if (!closed)
76
+ read.current(); }).catch(() => { if (!closed)
77
+ setError(true); });
78
+ return () => { closed = true; void player.dispose(); };
79
+ }, [message.id, access.url, audio]);
80
+ return error ? _jsx(Text, { accessibilityRole: "alert", children: "The recording could not play. Try playing it again." }) : controller ? _jsx(MessagingMediaOverlay, { controller: controller, audio: audio, appearance: design }) : null;
81
+ }
82
+ export function ExpoVoicemailMailbox(props) {
83
+ return _jsx(VoicemailMailbox, { ...props, renderRecording: (message, access, onRead) => _jsx(ExpoVoicemailPlayback, { message: message, access: access, onRead: onRead }) });
84
+ }
85
+ const videoAspects = new Map();
86
+ /** Recording content shared by independent chat messages and standalone inboxes. */
87
+ export function ExpoVoicemailCallAttachment({ client, message, appearance, recordingStorage = expoVoicemailRecordingStorage }) {
88
+ const openMenu = useContext(VoicemailMessageMenu), actions = useContext(VoicemailMessageActionContext);
89
+ const [file, setFile] = useState(null), [error, setError] = useState(false), [revision, setRevision] = useState(0);
90
+ const resume = useRef({ position: 0, playing: false });
91
+ const [aspect, setAspect] = useState(() => videoAspects.get(message.id) ?? .75);
92
+ const dimensions = (width, height) => { if (width <= 0 || height <= 0)
93
+ return; const next = width / height; videoAspects.set(message.id, next); if (videoAspects.size > 128)
94
+ videoAspects.delete(videoAspects.keys().next().value); setAspect(next); };
95
+ const audio = useMemo(() => createExpoMessagingAudioSession(), []), design = useMemo(() => appearance ?? defaultMessagingSettings('Voicemail').appearance, [appearance]);
96
+ useEffect(() => { let alive = true; setFile(null); setError(false); void loadVoicemailRecording(client, message, recordingStorage).then(uri => { if (alive)
97
+ setFile({ uri, autoPlay: resume.current.playing, resumeAtMs: resume.current.position, fileName: 'Voicemail.mp4', mimeType: message.mimeType, byteSize: message.byteSize, durationMs: message.durationMs }); }).catch(() => { if (alive)
98
+ setError(true); }); return () => { alive = false; }; }, [client, message.id, revision, recordingStorage]);
99
+ const readId = useRef(null);
100
+ const read = () => { if (message.direction !== 'sent' && !message.readAt && readId.current !== message.id) {
101
+ readId.current = message.id;
102
+ void client.markRead(message.id).catch(() => { readId.current = null; });
103
+ } };
104
+ return _jsx(StreamRecovery.Provider, { value: (_uri, position, playing) => { resume.current = { position, playing }; setRevision(x => x + 1); }, children: _jsx(View, { style: { paddingVertical: 0, gap: 2, alignSelf: 'flex-start', width: message.kind === 'video' ? voicemailVideoSize(aspect).width : 220 }, children: _jsxs(View, { style: message.kind === 'video' ? { ...voicemailVideoSize(aspect), ...bubbleCorners(design, message.direction === 'sent'), overflow: 'hidden' } : { width: 220, maxWidth: '100%', minHeight: 44 }, children: [file ? message.kind === 'voice' ? _jsx(VoicePlayer, { file: file, audio: audio, design: design, inline: { message: { id: message.id, clientMessageId: message.id, conversationId: message.connectionId, senderId: message.sender.userId, kind: 'voice', createdAt: new Date(message.createdAt).toISOString(), readAt: message.readAt ? new Date(message.readAt).toISOString() : null }, mine: message.direction === 'sent', heard: !!message.readAt, ink: message.direction === 'sent' ? design.colors.outgoingText : design.colors.incomingText, accent: design.colors.accent, showWaveform: design.showWaveform !== false, waveform: message.waveform, background: message.direction === 'sent' ? design.colors.outgoing : design.colors.incoming, footer: _jsxs(View, { style: { alignItems: 'flex-end' }, children: [_jsx(VoicemailMessageTitle, { compact: true, color: message.direction === 'sent' ? design.colors.outgoingText : design.colors.incomingText }), _jsx(VoicemailTimestamp, { message: message, appearance: design, placement: "inside" })] }), onOpen: () => { } }, onPlayed: read, onLongPress: openMenu }) : _jsx(ExpoVoicemailVideo, { onOpen: actions?.openMedia ? poster => { read(); actions.openMedia(message, file, poster); } : undefined, onForward: actions?.forward ? () => actions.forward(message) : undefined, onDelete: actions?.delete ? () => actions.delete(message) : undefined, file: file, audio: audio, design: design, onPlayed: read, onDimensions: dimensions, onLongPress: openMenu }) : message.kind === 'voice' ? _jsx(VoicePlayback, { waveform: message.waveform, loading: !error, ink: message.direction === 'sent' ? design.colors.outgoingText : design.colors.incomingText, accent: design.colors.accent, background: message.direction === 'sent' ? design.colors.outgoing : design.colors.incoming, mine: message.direction === 'sent', durationMs: message.durationMs, footer: _jsxs(View, { style: { alignItems: 'flex-end' }, children: [_jsx(VoicemailMessageTitle, { compact: true, color: message.direction === 'sent' ? design.colors.outgoingText : design.colors.incomingText }), _jsx(VoicemailTimestamp, { message: message, appearance: design, placement: "inside" })] }), onToggle: () => setRevision(x => x + 1) }) : _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: "Load voicemail", onPress: () => setRevision(x => x + 1), style: { flex: 1, minHeight: 44, justifyContent: 'center' }, children: error ? _jsx(Text, { style: { color: design.colors.accent }, children: "Try again" }) : _jsx(ActivityIndicator, { color: design.colors.accent }) }), message.kind === 'video' && _jsx(VideoMessageBadge, { durationMs: message.durationMs, label: _jsx(VoicemailMessageTitle, { compact: true, color: "#fff" }), time: _jsx(VoicemailTimestamp, { message: message, appearance: design, placement: "inside" }) })] }) }) });
105
+ }
106
+ export function ExpoVoicemailMessage({ actions, ...props }) {
107
+ const inherited = useMessagingAppearance();
108
+ const design = useMemo(() => inherited ?? props.appearance ?? defaultMessagingSettings('Voicemail').appearance, [inherited, props.appearance]);
109
+ return _jsx(VoicemailMessageBubble, { message: props.message, appearance: design, actions: actions, children: _jsx(ExpoVoicemailCallAttachment, { ...props, appearance: design }) });
110
+ }
package/dist/expo.d.ts CHANGED
@@ -1,3 +1,6 @@
1
+ export { withExpoDurableVoicemailStorage, clearExpoDurableVoicemailAccount } from './expo-voicemail-storage.js';
2
+ export { useCallingVoicemail } from './voicemail-session.js';
3
+ export { ExpoVoicemailComposer, ExpoVoicemailMailbox, ExpoVoicemailCallAttachment, ExpoVoicemailMessage, createExpoVoicemailStorage } from './expo-voicemail.js';
1
4
  export * from './expo-screen.js';
2
5
  export { ExpoMessenger, createExpoMessenger, createHostedExpoMessenger, type ExpoMessengerProps } from './expo-messenger.js';
3
6
  export { MessagingPopup } from './popup.js';
package/dist/expo.js CHANGED
@@ -1,3 +1,6 @@
1
+ export { withExpoDurableVoicemailStorage, clearExpoDurableVoicemailAccount } from './expo-voicemail-storage.js';
2
+ export { useCallingVoicemail } from './voicemail-session.js';
3
+ export { ExpoVoicemailComposer, ExpoVoicemailMailbox, ExpoVoicemailCallAttachment, ExpoVoicemailMessage, createExpoVoicemailStorage } from './expo-voicemail.js';
1
4
  export * from './expo-screen.js';
2
5
  export { ExpoMessenger, createExpoMessenger, createHostedExpoMessenger } from './expo-messenger.js';
3
6
  export { MessagingPopup } from './popup.js';
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ export declare const messagingHeaderActionStyle: {
3
+ width: number;
4
+ height: number;
5
+ alignItems: "center";
6
+ justifyContent: "center";
7
+ };
8
+ /** Compact adjacent actions retain a full-height touch area without extra gaps. */
9
+ export declare function MessagingHeaderActionGroup({ children }: {
10
+ children: React.ReactNode;
11
+ }): React.JSX.Element;
@@ -0,0 +1,7 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { View } from 'react-native';
3
+ export const messagingHeaderActionStyle = { width: 36, height: 44, alignItems: 'center', justifyContent: 'center' };
4
+ /** Compact adjacent actions retain a full-height touch area without extra gaps. */
5
+ export function MessagingHeaderActionGroup({ children }) {
6
+ return _jsx(View, { testID: "messaging-header-action-group", style: { flexDirection: 'row', alignItems: 'center', flexShrink: 0, gap: 0 }, children: children });
7
+ }
@@ -1,4 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { messagingHeaderActionStyle } from './header-action-group.js';
2
3
  import { Text } from './typography.js';
3
4
  import { useRobonoLocale } from './localization.js';
4
5
  import { useEffect, useRef, useState } from 'react';
@@ -41,7 +42,7 @@ export function MessagingHeaderCalls({ actions, name, group, color }) {
41
42
  } }; document.addEventListener('keydown', close, true); return () => document.removeEventListener('keydown', close, true); }, [visible]);
42
43
  useEffect(() => { pending.current = null; setVisible(false); setError(''); }, [name, group]);
43
44
  const choose = (kind) => { pending.current = kind; setVisible(false); };
44
- const button = (label, icon, press) => _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText(label), onPress: press, style: { width: 44, height: 44, alignItems: 'center', justifyContent: 'center' }, children: _jsx(MessageIcon, { name: icon, size: 23, color: color }) });
45
+ const button = (label, icon, press) => _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText(label), onPress: press, style: messagingHeaderActionStyle, children: _jsx(MessageIcon, { name: icon, size: 23, color: color }) });
45
46
  const row = (kind, label, detail) => _jsxs(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText(label), onPress: () => choose(kind), style: ({ pressed }) => ({ flexDirection: 'row', alignItems: 'center', gap: 16, minHeight: 80, padding: 12, borderRadius: 18, backgroundColor: pressed ? c.incoming : 'transparent' }), children: [_jsx(View, { style: { width: 48, height: 48, borderRadius: 24, backgroundColor: c.incoming, alignItems: 'center', justifyContent: 'center' }, children: _jsx(MessageIcon, { name: kind === 'phone' ? 'phone-portrait-outline' : 'phone', color: c.foreground, size: 24 }) }), _jsxs(View, { style: { flex: 1, gap: 4 }, children: [_jsx(Text, { style: { color: c.foreground, fontSize: 18, fontWeight: '600' }, children: uiText(label) }), _jsx(Text, { style: { color: c.secondary, fontSize: 15 }, children: uiText(detail) })] })] });
46
47
  return _jsxs(_Fragment, { children: [actions?.video && button(actions.videoLabel ?? 'Video call', 'video', () => void invoke('video')), (actions?.voice || validPhone) && button(uiText('Call {name}', { name }), 'phone', () => { if (!validPhone) {
47
48
  void invoke('voice');
@@ -0,0 +1,29 @@
1
+ import React from 'react';
2
+ import type { HistoryFollow } from './history-follow.js';
3
+ type Anchor = {
4
+ key: string;
5
+ top: number;
6
+ };
7
+ type Props = {
8
+ children: React.ReactNode;
9
+ historyKey: string;
10
+ following: HistoryFollow;
11
+ node: () => HTMLElement | null;
12
+ };
13
+ /** RN Web does not implement native maintainVisibleContentPosition. Capture the
14
+ * visible row before React changes the DOM, then preserve its screen position. */
15
+ export declare class HistoryScrollAnchor extends React.Component<Props, {}, Anchor | null> {
16
+ private host;
17
+ private anchor;
18
+ private observer;
19
+ private capture;
20
+ private onScroll;
21
+ private preserve;
22
+ private observe;
23
+ componentDidMount(): void;
24
+ componentWillUnmount(): void;
25
+ getSnapshotBeforeUpdate(previous: Props): Anchor | null;
26
+ componentDidUpdate(_previous: Props, _state: {}, anchor: Anchor | null): void;
27
+ render(): React.ReactNode;
28
+ }
29
+ export {};
@@ -0,0 +1,74 @@
1
+ import React from 'react';
2
+ import { Platform } from 'react-native';
3
+ const readingContent = (row) => row.querySelector('[data-testid^="message-"][data-testid$="-incoming"],[data-testid^="message-"][data-testid$="-outgoing"]') ?? row;
4
+ /** RN Web does not implement native maintainVisibleContentPosition. Capture the
5
+ * visible row before React changes the DOM, then preserve its screen position. */
6
+ export class HistoryScrollAnchor extends React.Component {
7
+ host = null;
8
+ anchor = null;
9
+ observer = null;
10
+ capture() {
11
+ const host = this.props.node();
12
+ if (!host)
13
+ return null;
14
+ const viewport = host.getBoundingClientRect();
15
+ const rows = Array.from(host.querySelectorAll('[data-history-key]'));
16
+ const row = rows.find(row => { const rect = row.getBoundingClientRect(); return rect.top > viewport.top + 10 && rect.bottom < viewport.bottom - 10; }) ?? rows.find(row => { const rect = row.getBoundingClientRect(); return rect.bottom > viewport.top && rect.top < viewport.bottom; });
17
+ return row ? { key: row.dataset.historyKey, top: readingContent(row).getBoundingClientRect().top } : null;
18
+ }
19
+ onScroll = () => {
20
+ if (this.props.following.current)
21
+ this.anchor = null;
22
+ else if (this.props.following.isInteracting || !this.anchor)
23
+ this.anchor = this.capture();
24
+ };
25
+ preserve = () => {
26
+ if (this.props.following.current) {
27
+ this.anchor = null;
28
+ return;
29
+ }
30
+ if (this.props.following.isInteracting) {
31
+ this.anchor = this.capture();
32
+ return;
33
+ }
34
+ const host = this.props.node(), anchor = this.anchor;
35
+ if (!host || !anchor)
36
+ return;
37
+ const row = Array.from(host.querySelectorAll('[data-history-key]')).find(row => row.dataset.historyKey === anchor.key);
38
+ if (row)
39
+ host.scrollTop -= readingContent(row).getBoundingClientRect().top - anchor.top;
40
+ else
41
+ this.anchor = this.capture();
42
+ };
43
+ observe() {
44
+ if (Platform.OS !== 'web')
45
+ return;
46
+ const host = this.props.node();
47
+ if (!host)
48
+ return;
49
+ if (this.host !== host) {
50
+ this.host?.removeEventListener('scroll', this.onScroll);
51
+ this.host = host;
52
+ host.addEventListener('scroll', this.onScroll);
53
+ }
54
+ this.observer?.disconnect();
55
+ if (typeof ResizeObserver !== 'undefined') {
56
+ this.observer ??= new ResizeObserver(this.preserve);
57
+ if (host.firstElementChild)
58
+ this.observer.observe(host.firstElementChild);
59
+ }
60
+ }
61
+ componentDidMount() { this.observe(); }
62
+ componentWillUnmount() { this.observer?.disconnect(); this.host?.removeEventListener('scroll', this.onScroll); }
63
+ getSnapshotBeforeUpdate(previous) {
64
+ if (Platform.OS !== 'web' || this.props.following.current || previous.historyKey !== this.props.historyKey)
65
+ return null;
66
+ return this.anchor ?? this.capture();
67
+ }
68
+ componentDidUpdate(_previous, _state, anchor) {
69
+ this.anchor = anchor;
70
+ this.observe();
71
+ this.preserve();
72
+ }
73
+ render() { return this.props.children; }
74
+ }
@@ -0,0 +1,18 @@
1
+ /** Sticky reading intent for inverted chat history. Layout-induced scroll events
2
+ * must not be mistaken for the reader moving away from the newest message. */
3
+ export declare class HistoryFollow {
4
+ private request;
5
+ private cancel;
6
+ current: boolean;
7
+ private interacting;
8
+ private frame;
9
+ get isInteracting(): boolean;
10
+ constructor(request?: (callback: () => void) => number, cancel?: (id: number) => void);
11
+ observe(offset: number): boolean;
12
+ begin(): void;
13
+ end(offset: number): boolean;
14
+ pause(): void;
15
+ reset(): void;
16
+ cancelLayout(): void;
17
+ layout(scroll: () => void): void;
18
+ }
@@ -0,0 +1,35 @@
1
+ /** Sticky reading intent for inverted chat history. Layout-induced scroll events
2
+ * must not be mistaken for the reader moving away from the newest message. */
3
+ export class HistoryFollow {
4
+ request;
5
+ cancel;
6
+ current = true;
7
+ interacting = false;
8
+ frame = null;
9
+ get isInteracting() { return this.interacting; }
10
+ constructor(request = callback => requestAnimationFrame(callback), cancel = id => cancelAnimationFrame(id)) {
11
+ this.request = request;
12
+ this.cancel = cancel;
13
+ }
14
+ observe(offset) {
15
+ if (this.interacting)
16
+ this.current = offset < 80;
17
+ return this.current;
18
+ }
19
+ begin() { this.cancelLayout(); this.interacting = true; }
20
+ end(offset) { const wasInteracting = this.interacting; this.observe(offset); this.interacting = false; return wasInteracting; }
21
+ pause() { this.cancelLayout(); this.current = false; this.interacting = false; }
22
+ reset() { this.cancelLayout(); this.current = true; this.interacting = false; }
23
+ cancelLayout() { if (this.frame !== null)
24
+ this.cancel(this.frame); this.frame = null; }
25
+ layout(scroll) {
26
+ if (!this.current || this.interacting)
27
+ return;
28
+ this.cancelLayout();
29
+ this.frame = this.request(() => {
30
+ this.frame = null;
31
+ if (this.current && !this.interacting)
32
+ scroll();
33
+ });
34
+ }
35
+ }
package/dist/index.d.ts CHANGED
@@ -1,3 +1,12 @@
1
+ export { HistoryFollow } from './history-follow.js';
2
+ export { MessagingHeaderActionGroup, messagingHeaderActionStyle } from './header-action-group.js';
3
+ export { MessagingTimeFormatProvider } from './message-time.js';
4
+ export { VoicemailMessageBubble, type VoicemailMessageActions } from './voicemail-message.js';
5
+ export { VoicemailFlow, type VoicemailCapture, type VoicemailOption, type VoicemailPhase } from './voicemail-flow.js';
6
+ export { MessengerCallHistoryItem, CallingTimelineProvider, useCallingConversationHistory, type CallingTimelineEntry } from './calling-timeline.js';
7
+ export { useCallingVoicemail } from './voicemail-session.js';
8
+ export { VoicemailComposer, VoicemailInbox, VoicemailMailbox, useConversationVoicemail } from './voicemail.js';
9
+ export type { VoicemailAPI, VoicemailAppearance, VoicemailUploadAPI, VoicemailRecord, VoicemailDraft } from './voicemail.js';
1
10
  export { MessagingLinkedAppsScreen } from './linked-apps.js';
2
11
  export type { MessagingLinkedApps, MessagingLinkedNetwork, MessagingLinkedContact } from './linked-apps.js';
3
12
  export { messagingLanguages } from './account-pages.js';
@@ -73,6 +82,8 @@ export interface AttachmentChoice {
73
82
  durationMs?: number;
74
83
  }
75
84
  export interface MessagingScreenProps {
85
+ /** Adopt a recorded local file into the ordinary, permission-checked message outbox. */
86
+ sendLocalRecording?: (file: import('./media-controller.js').LocalMessagingMedia, kind: 'voice' | 'video') => Promise<void>;
76
87
  /** Automatically supplied by ExpoMessenger/WebMessenger; single-chat hosts can supply their own authorized actions. */
77
88
  conversationActions?: ConversationActions;
78
89
  /** Standard header configuration; no replacement Header component required. */
@@ -224,12 +235,13 @@ export declare function MessageDeletion({ messages, onClose }: {
224
235
  export declare function MessagingList(): React.JSX.Element;
225
236
  export declare function MessagingComposer(): React.JSX.Element;
226
237
  /** Account navigation. Mount in the inbox/app toolbar, never in a contact menu. */
227
- export declare function MessagingAccountMenu({ inbox, onNewGroup, onMaps, onPublicRooms }?: {
238
+ export declare function MessagingAccountMenu({ inbox, onNewGroup, onMaps, onPublicRooms, onVoicemail }?: {
228
239
  inbox?: import('@robono/messaging').MessagingInboxClient; /** @deprecated Use MessagingInbox.onNewConversation for the floating Message button. */
229
240
  onNewConversation?: () => void;
230
241
  onNewGroup?: () => void;
231
242
  onMaps?: () => void;
232
243
  onPublicRooms?: () => void;
244
+ onVoicemail?: () => void;
233
245
  }): React.JSX.Element;
234
246
  export declare function MessagingConversation(): React.JSX.Element;
235
247
  /** Embed inside your app's safe area and navigation. No engine, push or global audio side effects. */
@@ -239,3 +251,4 @@ export type { PlaybackProps } from './media-ui.js';
239
251
  export type { InboxViewMemory } from './inbox-view.js';
240
252
  export type { MessagingDirectoryContact, MessagingDirectoryOptions } from './contact-directory.js';
241
253
  export { MessagingBackupScreen } from './backup.js';
254
+ export type { VoicemailRecordingStorage } from './voicemail-recording.js';