@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
package/dist/index.js CHANGED
@@ -1,4 +1,18 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { HistoryScrollAnchor } from './history-anchor.js';
3
+ import { HistoryFollow } from './history-follow.js';
4
+ export { HistoryFollow } from './history-follow.js';
5
+ import { MessagingHeaderActionGroup } from './header-action-group.js';
6
+ export { MessagingHeaderActionGroup, messagingHeaderActionStyle } from './header-action-group.js';
7
+ import { VideoMessageBadge } from './video-message-badge.js';
8
+ import { MessagingTimeFormatProvider } from './message-time.js';
9
+ export { MessagingTimeFormatProvider } from './message-time.js';
10
+ export { VoicemailMessageBubble } from './voicemail-message.js';
11
+ export { VoicemailFlow } from './voicemail-flow.js';
12
+ export { MessengerCallHistoryItem, CallingTimelineProvider, useCallingConversationHistory } from './calling-timeline.js';
13
+ import { CallingTimeline } from './calling-timeline.js';
14
+ export { useCallingVoicemail } from './voicemail-session.js';
15
+ export { VoicemailComposer, VoicemailInbox, VoicemailMailbox, useConversationVoicemail } from './voicemail.js';
2
16
  import { resolveMessagingVoice } from '@robono/messaging';
3
17
  export { MessagingLinkedAppsScreen } from './linked-apps.js';
4
18
  import { MessagingAccountPageScreen, messagingAccountPages, messagingAccountPageLabels } from './account-pages.js';
@@ -10,7 +24,7 @@ export { messagingHeaderColors } from './header-colors.js';
10
24
  export { MessagingReviewInbox } from './reviews.js';
11
25
  import { messageParts, selectMessagePart, composeMessageItems } from '@robono/messaging';
12
26
  import { DeliveryBar } from './delivery-bar.js';
13
- import { bubbleCorners, bubbleDelivery } from './bubble-design.js';
27
+ import { bubbleCorners, bubbleDelivery, messageSpacing } from './bubble-design.js';
14
28
  import { compareMessageOrder, isMessageIdentity } from '@robono/messaging';
15
29
  import { messagingScreenAppearance } from '@robono/messaging';
16
30
  import { messagingHeaderOrder } from '@robono/messaging';
@@ -202,14 +216,14 @@ function MessagingProviderContent({ children, ...props }) {
202
216
  setEditing, setForwarding, setDeleting, selection: selected, setSelection, saved, saving, toggleSaved, setSavedOpen,
203
217
  design,
204
218
  };
205
- return _jsx(Context.Provider, { value: value, children: _jsx(MessagingTypography, { appearance: value.design, screen: styleScreen, children: _jsxs(MessagingPopupHost, { children: [children, discussion && _jsx(GroupDiscussion, { threadRoot: discussion.threadRoot, onClose: () => setDiscussion(null) }), forwarding.length > 0 && _jsx(MessagingForward, { messages: forwarding, client: props.client, appearance: value.design, participants: props.participants, userId: props.userId, onClose: () => setForwarding([]) }), _jsx(MessageDeletion, { messages: deleting, onClose: () => setDeleting([]) }), savedOpen && _jsx(SavedMessagesPopup, { records: saved, appearance: value.design, onClose: () => setSavedOpen(false), onOpen: async (record) => { setSavedOpen(false); try {
206
- if (!props.openSavedAttachment)
207
- throw Error('Saved attachments cannot be opened here.');
208
- await props.openSavedAttachment(record);
209
- }
210
- catch (e) {
211
- setSavedError(e instanceof Error ? e.message : uiText("This saved attachment could not be opened."));
212
- } }, onRemove: async (key) => { await props.client.removeSavedMessage(key); setSaved(await props.client.savedMessages()); } }), !!savedError && _jsxs(MessagingPopup, { compact: true, contentWidth: 640, title: uiText("Saved"), foreground: value.design.colors.foreground, background: value.design.colors.background, onClose: () => setSavedError(''), children: [_jsx(Text, { accessibilityRole: "alert", style: { color: messagingPopupColors.foreground }, children: savedError }), _jsx(Pressable, { accessibilityRole: "button", onPress: () => setSavedError(''), style: { minHeight: 44, alignSelf: 'flex-end', justifyContent: 'center' }, children: _jsx(Text, { style: { color: value.design.colors.accent }, children: uiText("OK") }) })] })] }) }) });
219
+ return _jsx(Context.Provider, { value: value, children: _jsx(MessagingTimeFormatProvider, { format: formatMessageTime, children: _jsx(MessagingTypography, { appearance: value.design, screen: styleScreen, children: _jsxs(MessagingPopupHost, { children: [children, discussion && _jsx(GroupDiscussion, { threadRoot: discussion.threadRoot, onClose: () => setDiscussion(null) }), forwarding.length > 0 && _jsx(MessagingForward, { messages: forwarding, client: props.client, appearance: value.design, participants: props.participants, userId: props.userId, onClose: () => setForwarding([]) }), _jsx(MessageDeletion, { messages: deleting, onClose: () => setDeleting([]) }), savedOpen && _jsx(SavedMessagesPopup, { records: saved, appearance: value.design, onClose: () => setSavedOpen(false), onOpen: async (record) => { setSavedOpen(false); try {
220
+ if (!props.openSavedAttachment)
221
+ throw Error('Saved attachments cannot be opened here.');
222
+ await props.openSavedAttachment(record);
223
+ }
224
+ catch (e) {
225
+ setSavedError(e instanceof Error ? e.message : uiText("This saved attachment could not be opened."));
226
+ } }, onRemove: async (key) => { await props.client.removeSavedMessage(key); setSaved(await props.client.savedMessages()); } }), !!savedError && _jsxs(MessagingPopup, { compact: true, contentWidth: 640, title: uiText("Saved"), foreground: value.design.colors.foreground, background: value.design.colors.background, onClose: () => setSavedError(''), children: [_jsx(Text, { accessibilityRole: "alert", style: { color: messagingPopupColors.foreground }, children: savedError }), _jsx(Pressable, { accessibilityRole: "button", onPress: () => setSavedError(''), style: { minHeight: 44, alignSelf: 'flex-end', justifyContent: 'center' }, children: _jsx(Text, { style: { color: value.design.colors.accent }, children: uiText("OK") }) })] })] }) }) }) });
213
227
  }
214
228
  export function GroupDiscussion({ threadRoot, onClose }) {
215
229
  const messagingPopupColors = useMessagingPopupColors(undefined, threadRoot ? 'replies' : 'pins');
@@ -328,7 +342,7 @@ export function MessagingHeader({ children } = {}) {
328
342
  backgroundColor: c.incoming,
329
343
  alignItems: "center",
330
344
  justifyContent: "center",
331
- }, children: _jsx(Text, { style: { color: c.incomingText }, children: state.conversation?.kind === 'group' ? (state.conversation.name ?? 'Group').slice(0, 1) : contact.name.slice(0, 1) }) }))), _jsxs(View, { style: { flex: 1, minWidth: 0 }, children: [_jsx(Text, { numberOfLines: 1, style: { color: header.foreground, fontSize: chatDesign?.titleSize ?? 18, lineHeight: Math.ceil((chatDesign?.titleSize ?? 18) * 1.25), textAlign: chatDesign?.titleAlign ?? 'left', fontWeight: "800" }, children: state.conversation?.kind === 'group' ? state.conversation.name : contact.name }), _jsx(MessagingActivity, { ink: header.foreground })] })] }), messagingHeaderOrder(design).map(action => _jsx(React.Fragment, { children: action === 'switcher' ? chatDesign?.showSwitcher !== false && _jsx(ConversationSelector, { options: headerOptions, selectedId: state.conversationId, color: header.foreground, background: header.background }) : action === 'close' ? chatDesign?.showClose !== false && headerOptions?.onClose && _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText("Close conversation"), onPress: headerOptions.onClose, style: { width: 44, height: 44, alignItems: "center", justifyContent: "center" }, children: _jsx(MessageIcon, { name: "close", color: header.foreground, size: 24 }) }) : action === 'calls' ? _jsxs(_Fragment, { children: [children, components?.HeaderActions && _jsx(components.HeaderActions, { conversationId: state.conversationId, contact: contact, appearance: design }), state.conversation?.canSend !== false && _jsx(MessagingHeaderCalls, { actions: callActions ? { ...callActions, ...(chatDesign?.showVoiceCall === false ? { voice: undefined, phoneNumber: undefined } : {}), ...(chatDesign?.showVideoCall === false ? { video: undefined } : {}) } : undefined, name: state.conversation?.kind === 'group' ? (state.conversation.name ?? 'Group') : contact.name, group: state.conversation?.kind === 'group', color: header.foreground }, state.conversationId)] }) : action === 'privacy' ? null : _jsx(View, { style: { width: 44, height: 44 }, children: (onContactOptions || extrasState?.available.privacyLens || extrasState?.privacyLens || conversationActions || state.settings?.enabled || state.conversation?.safety || state.searchAvailable || state.scheduledMessagesAvailable || translationAvailable) && (_jsx(Pressable, { accessibilityRole: "button", testID: "messaging-contact-options", accessibilityLabel: uiText("Contact options"), ref: menuButton, accessibilityState: { expanded: safetyOpen }, onPress: onContactOptions ?? openContactMenu, style: { width: 44, height: 44, alignItems: "center", justifyContent: "center" }, children: _jsx(MessageIcon, { name: "more", color: header.foreground, size: 25 }) })) }) }, action)), safetyOpen && _jsx(MessagingSafety, { onMedia: state.sharedMediaAvailable ? () => { setSafetyOpen(false); setDetailsTab('media'); setDetailsOpen(true); } : undefined, onOptions: state.presence?.visibilityAvailable || conversationActions || extrasState?.available.privacyLens || extrasState?.privacyLens ? () => { setSafetyOpen(false); setOptionsOpen(true); } : undefined, onScheduled: state.scheduledMessagesAvailable ? () => { setSafetyOpen(false); setScheduledOpen(true); } : undefined, onDetails: state.settings?.enabled ? () => { setSafetyOpen(false); setDetailsTab('profile'); setDetailsOpen(true); } : undefined, onPins: state.discussionAvailable ? () => { setSafetyOpen(false); openDiscussion(); } : undefined, menuAnchor: menuAnchor, client: client, state: state, appearance: design, name: state.conversation?.kind === 'group' ? (state.conversation.name ?? 'Conversation') : contact.name, onSearch: state.searchAvailable && state.settings?.enabled ? () => { setSafetyOpen(false); setSearchOpen(true); } : undefined, onClose: () => setSafetyOpen(false), children: translationAvailable && _jsx(TranslationSettings, { client: client, appearance: design, preference: state.translationPreference, language: languageTools?.preferredLanguage ?? language, sourceLanguage: contact.language, defaults: state.settings?.languageDefaults, preferredVoice: languageTools?.preferredVoice, VoiceSample: components?.TranslationVoice, sampleBaseUrl: languageTools?.voiceSampleBaseUrl, voiceAvailable: languageTools?.voiceOutput !== false && !!components?.TranslationVoice, onSaved: () => setSafetyOpen(false) }, state.conversationId) })] }), scheduledOpen && _jsx(ScheduledMessages, { client: client, accent: c.accent, onClose: () => setScheduledOpen(false) }, state.conversationId), groupOpen && _jsx(MessagingGroupEditor, { client: client, userId: userId, contacts: participants ?? {}, conversation: state.conversation, groups: state.settings?.groups, accent: c.accent, onClose: () => setGroupOpen(false), onSaved: () => setGroupOpen(false) }), moderationOpen && _jsx(MessagingRoomModeration, { client: client, userId: userId, participants: participants, accent: c.accent, onClose: () => setModerationOpen(false) }), optionsOpen && _jsx(ChatOptions, { online: state.presence?.visibilityAvailable ? { hidden: state.presence.hidden === true, set: hidden => client.setOnlineStatusHidden(hidden) } : undefined, actions: conversationActions, accent: c.accent, onClose: () => setOptionsOpen(false), privacy: extras && extrasState && (extrasState.available.privacyLens || extrasState.privacyLens) ? { enabled: extrasState.privacyLens, set: enabled => extras.setPrivacy(enabled) } : undefined }), detailsOpen && _jsx(ConversationDetails, { initialTab: detailsTab, onOptions: state.presence?.visibilityAvailable || conversationActions ? () => setOptionsOpen(true) : undefined, onModerate: () => setModerationOpen(true), onEditGroup: () => setGroupOpen(true), onLeft: onBack, client: client, state: state, userId: userId, contact: contact, participants: participants, accent: c.accent, onClose: () => setDetailsOpen(false), attachmentPreview: attachmentPreview, openAttachment: openAttachment }), searchOpen && state.searchAvailable && state.settings?.enabled && _jsx(MessagingSearch, { client: client, appearance: design, onClose: () => setSearchOpen(false), resolveName: id => id === userId ? 'You' : participants?.[id]?.name ?? (state.conversation?.kind === 'direct' ? contact.name : 'Chat member') }, state.conversationId)] }));
345
+ }, children: _jsx(Text, { style: { color: c.incomingText }, children: state.conversation?.kind === 'group' ? (state.conversation.name ?? 'Group').slice(0, 1) : contact.name.slice(0, 1) }) }))), _jsxs(View, { style: { flex: 1, minWidth: 0 }, children: [_jsx(Text, { numberOfLines: 1, style: { color: header.foreground, fontSize: chatDesign?.titleSize ?? 18, lineHeight: Math.ceil((chatDesign?.titleSize ?? 18) * 1.25), textAlign: chatDesign?.titleAlign ?? 'left', fontWeight: "800" }, children: state.conversation?.kind === 'group' ? state.conversation.name : contact.name }), _jsx(MessagingActivity, { ink: header.foreground })] })] }), messagingHeaderOrder(design).map(action => _jsx(React.Fragment, { children: action === 'switcher' ? chatDesign?.showSwitcher !== false && _jsx(ConversationSelector, { options: headerOptions, selectedId: state.conversationId, color: header.foreground, background: header.background }) : action === 'close' ? chatDesign?.showClose !== false && headerOptions?.onClose && _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText("Close conversation"), onPress: headerOptions.onClose, style: { width: 44, height: 44, alignItems: "center", justifyContent: "center" }, children: _jsx(MessageIcon, { name: "close", color: header.foreground, size: 24 }) }) : action === 'calls' ? _jsxs(MessagingHeaderActionGroup, { children: [children, components?.HeaderActions && _jsx(components.HeaderActions, { conversationId: state.conversationId, contact: contact, appearance: design }), state.conversation?.canSend !== false && _jsx(MessagingHeaderCalls, { actions: callActions ? { ...callActions, ...(chatDesign?.showVoiceCall === false ? { voice: undefined, phoneNumber: undefined } : {}), ...(chatDesign?.showVideoCall === false ? { video: undefined } : {}) } : undefined, name: state.conversation?.kind === 'group' ? (state.conversation.name ?? 'Group') : contact.name, group: state.conversation?.kind === 'group', color: header.foreground }, state.conversationId)] }) : action === 'privacy' ? null : _jsx(View, { style: { width: 44, height: 44 }, children: (onContactOptions || extrasState?.available.privacyLens || extrasState?.privacyLens || conversationActions || state.settings?.enabled || state.conversation?.safety || state.searchAvailable || state.scheduledMessagesAvailable || translationAvailable) && (_jsx(Pressable, { accessibilityRole: "button", testID: "messaging-contact-options", accessibilityLabel: uiText("Contact options"), ref: menuButton, accessibilityState: { expanded: safetyOpen }, onPress: onContactOptions ?? openContactMenu, style: { width: 44, height: 44, alignItems: "center", justifyContent: "center" }, children: _jsx(MessageIcon, { name: "more", color: header.foreground, size: 25 }) })) }) }, action)), safetyOpen && _jsx(MessagingSafety, { onMedia: state.sharedMediaAvailable ? () => { setSafetyOpen(false); setDetailsTab('media'); setDetailsOpen(true); } : undefined, onOptions: state.presence?.visibilityAvailable || conversationActions || extrasState?.available.privacyLens || extrasState?.privacyLens ? () => { setSafetyOpen(false); setOptionsOpen(true); } : undefined, onScheduled: state.scheduledMessagesAvailable ? () => { setSafetyOpen(false); setScheduledOpen(true); } : undefined, onDetails: state.settings?.enabled ? () => { setSafetyOpen(false); setDetailsTab('profile'); setDetailsOpen(true); } : undefined, onPins: state.discussionAvailable ? () => { setSafetyOpen(false); openDiscussion(); } : undefined, menuAnchor: menuAnchor, client: client, state: state, appearance: design, name: state.conversation?.kind === 'group' ? (state.conversation.name ?? 'Conversation') : contact.name, onSearch: state.searchAvailable && state.settings?.enabled ? () => { setSafetyOpen(false); setSearchOpen(true); } : undefined, onClose: () => setSafetyOpen(false), children: translationAvailable && _jsx(TranslationSettings, { client: client, appearance: design, preference: state.translationPreference, language: languageTools?.preferredLanguage ?? language, sourceLanguage: contact.language, defaults: state.settings?.languageDefaults, preferredVoice: languageTools?.preferredVoice, VoiceSample: components?.TranslationVoice, sampleBaseUrl: languageTools?.voiceSampleBaseUrl, voiceAvailable: languageTools?.voiceOutput !== false && !!components?.TranslationVoice, onSaved: () => setSafetyOpen(false) }, state.conversationId) })] }), scheduledOpen && _jsx(ScheduledMessages, { client: client, accent: c.accent, onClose: () => setScheduledOpen(false) }, state.conversationId), groupOpen && _jsx(MessagingGroupEditor, { client: client, userId: userId, contacts: participants ?? {}, conversation: state.conversation, groups: state.settings?.groups, accent: c.accent, onClose: () => setGroupOpen(false), onSaved: () => setGroupOpen(false) }), moderationOpen && _jsx(MessagingRoomModeration, { client: client, userId: userId, participants: participants, accent: c.accent, onClose: () => setModerationOpen(false) }), optionsOpen && _jsx(ChatOptions, { online: state.presence?.visibilityAvailable ? { hidden: state.presence.hidden === true, set: hidden => client.setOnlineStatusHidden(hidden) } : undefined, actions: conversationActions, accent: c.accent, onClose: () => setOptionsOpen(false), privacy: extras && extrasState && (extrasState.available.privacyLens || extrasState.privacyLens) ? { enabled: extrasState.privacyLens, set: enabled => extras.setPrivacy(enabled) } : undefined }), detailsOpen && _jsx(ConversationDetails, { initialTab: detailsTab, onOptions: state.presence?.visibilityAvailable || conversationActions ? () => setOptionsOpen(true) : undefined, onModerate: () => setModerationOpen(true), onEditGroup: () => setGroupOpen(true), onLeft: onBack, client: client, state: state, userId: userId, contact: contact, participants: participants, accent: c.accent, onClose: () => setDetailsOpen(false), attachmentPreview: attachmentPreview, openAttachment: openAttachment }), searchOpen && state.searchAvailable && state.settings?.enabled && _jsx(MessagingSearch, { client: client, appearance: design, onClose: () => setSearchOpen(false), resolveName: id => id === userId ? 'You' : participants?.[id]?.name ?? (state.conversation?.kind === 'direct' ? contact.name : 'Chat member') }, state.conversationId)] }));
332
346
  }
333
347
  const mediaNames = {
334
348
  voice: "Voice message",
@@ -409,7 +423,7 @@ function MediaContent({ message, ink, footer, onOpen, onLongPress, sendRetry })
409
423
  const width = source?.width ?? target?.naturalWidth, height = source?.height ?? target?.naturalHeight;
410
424
  if (width && height && preview.uri)
411
425
  decodedSize(preview.uri, width, height);
412
- }, onError: onImageError, style: { width: '100%', height: '100%' } }) : _jsx(MessageIcon, { name: message.kind, color: ink, size: 36 }), failed && !preview.uri && _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText('Retry preview'), onPress: event => { event.stopPropagation(); retry(); }, style: { position: 'absolute', bottom: 6, right: 6, minHeight: 44, paddingHorizontal: 12, justifyContent: 'center', backgroundColor: design.colors.incoming, borderRadius: 18 }, children: _jsx(Text, { style: { color: design.colors.accent }, children: uiText('Retry preview') }) }), sendRetry && _jsx(View, { testID: "media-send-retry", style: { position: 'absolute', backgroundColor: design.colors.incoming, borderRadius: 18, paddingHorizontal: 12 }, children: sendRetry }), message.kind === 'video' && !sendRetry && _jsxs(_Fragment, { children: [_jsx(View, { style: { position: 'absolute', borderRadius: 24, padding: 10, backgroundColor: '#00000099' }, children: _jsx(MessageIcon, { name: "play", color: "#ffffff" }) }), _jsx(Text, { style: { position: 'absolute', left: 8, bottom: 8, color: '#ffffff', backgroundColor: '#000000aa', borderRadius: 4, paddingHorizontal: 5, fontSize: 12 }, children: duration(message.media?.durationMs) })] })] }) });
426
+ }, onError: onImageError, style: { width: '100%', height: '100%' } }) : _jsx(MessageIcon, { name: message.kind, color: ink, size: 36 }), failed && !preview.uri && _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText('Retry preview'), onPress: event => { event.stopPropagation(); retry(); }, style: { position: 'absolute', bottom: 6, right: 6, minHeight: 44, paddingHorizontal: 12, justifyContent: 'center', backgroundColor: design.colors.incoming, borderRadius: 18 }, children: _jsx(Text, { style: { color: design.colors.accent }, children: uiText('Retry preview') }) }), sendRetry && _jsx(View, { testID: "media-send-retry", style: { position: 'absolute', backgroundColor: design.colors.incoming, borderRadius: 18, paddingHorizontal: 12 }, children: sendRetry }), message.kind === 'video' && !sendRetry && _jsxs(_Fragment, { children: [_jsx(View, { style: { position: 'absolute', borderRadius: 24, padding: 10, backgroundColor: '#00000099' }, children: _jsx(MessageIcon, { name: "play", color: "#ffffff" }) }), _jsx(VideoMessageBadge, { durationMs: message.media?.durationMs })] })] }) });
413
427
  return _jsxs(View, { testID: "file-message-content", style: { flexDirection: 'row', alignItems: 'center', gap: 10, width: 220, maxWidth: '100%', minHeight: 56, paddingHorizontal: 12, paddingVertical: 6, ...bubbleCorners(design, message.senderId === userId), ...(message.senderId === userId && design.messageStatus?.style === 'circle' ? { paddingRight: 28 } : {}) }, children: [_jsx(MessageIcon, { name: "document", color: design.colors.accent, size: 24 }), _jsxs(View, { style: { flex: 1, gap: 2 }, children: [_jsx(Text, { numberOfLines: 2, style: { color: ink, fontSize: 14, fontWeight: '600' }, children: message.media?.fileName ?? uiText("File") }), _jsxs(Text, { style: { color: ink, fontSize: 12, opacity: 0.75 }, children: [message.media?.fileName?.split('.').pop()?.toUpperCase(), " \u00B7 ", fileSize(message.media?.byteSize)] }), sendRetry] })] });
414
428
  }
415
429
  function messageTimeLabel(message, format, text) { return (message.editedAt && !message.deleted ? text('edited') + ' · ' : '') + format(message.createdAt); }
@@ -466,7 +480,7 @@ const MessagingBubbleView = React.memo(function MessagingBubbleView({ message, p
466
480
  const circleStatus = mine && status.style === 'circle';
467
481
  const timePosition = design.messageTime?.position ?? 'slide', circlePosition = design.messageStatus?.position ?? 'inside';
468
482
  const statusLabel = uiText(notice.text ?? (status.phase === 'failed' ? 'Message not sent' : status.phase === 'sent' ? 'Sending message' : status.phase === 'consumed' ? (message.kind === 'voice' ? 'Heard' : message.kind === 'video' ? 'Watched' : 'Seen') : 'Delivered'));
469
- const messageGap = design.presentation?.messageSpacing === 'compact' ? 4 : design.presentation?.messageSpacing === 'relaxed' ? 12 : 8;
483
+ const messageGap = messageSpacing(design);
470
484
  const visual = message.kind === 'image' || message.kind === 'video', voice = message.kind === 'voice';
471
485
  const grouped = ui.grouped;
472
486
  const [error, setError] = useState(''), [busy, setBusy] = useState(false), [actions, setActions] = useState(false), [reportOpen, setReportOpen] = useState(false), [roomRemoval, setRoomRemoval] = useState(false);
@@ -644,7 +658,7 @@ const MessagingHistoryRow = React.memo(function MessagingHistoryRow({ item, prev
644
658
  const date = new Date(item.createdAt), start = !previous || date.toDateString() !== new Date(previous.createdAt).toDateString();
645
659
  const checked = selection.some(m => m.id === item.id), selectable = selection.length > 0 && !item.pendingStatus && !item.deleted;
646
660
  const toggle = () => setSelection(checked ? selection.filter(m => m.id !== item.id) : [...selection, item]);
647
- return _jsxs(View, { testID: highlighted ? 'focused-message' : undefined, style: highlighted || checked ? { backgroundColor: design.colors.accent + '20', borderRadius: 8 } : undefined, children: [start && design.screens?.chat?.showDates !== false && _jsx(Text, { testID: "messaging-date-separator", style: { alignSelf: 'center', fontSize: design.screens?.chat?.dateSize ?? 12, color: design.screens?.chat?.dateText ?? design.colors.secondary, backgroundColor: design.screens?.chat?.dateBackground ?? chatSurface(design.colors.background), borderRadius: 7, paddingHorizontal: 12, paddingVertical: 5, marginTop: 4, marginBottom: 10 }, children: date.toDateString() === new Date().toDateString() ? uiText("Today") : date.toLocaleDateString(uiLocale, { month: 'short', day: 'numeric' }) }), _jsx(View, { style: { paddingLeft: selection.length ? 32 : 0 }, pointerEvents: selection.length ? 'none' : 'auto', accessibilityElementsHidden: selection.length > 0, importantForAccessibility: selection.length ? 'no-hide-descendants' : 'auto', ...(Platform.OS === 'web' && selection.length ? { 'aria-hidden': true } : {}), children: Message ? _jsx(Message, { message: item }) : _jsx(MessagingBubbleItems, { message: item, pendingStatus: item.pendingStatus, ui: bubbleUI }) }), selectable && _jsx(Pressable, { accessibilityRole: "checkbox", accessibilityLabel: uiText('Select message: {message}', { message: item.text || item.media?.fileName || uiText(mediaNames[item.kind] || 'Message') }), accessibilityState: { checked }, onPress: toggle, style: { position: 'absolute', inset: 0, justifyContent: 'center' }, children: _jsx(View, { style: { width: 24, height: 24, borderRadius: 12, borderWidth: 1, borderColor: design.colors.accent, backgroundColor: checked ? design.colors.accent : design.colors.background, alignItems: 'center', justifyContent: 'center' }, children: checked && _jsx(MessageIcon, { name: "check", size: 16, color: "#ffffff" }) }) })] });
661
+ return _jsxs(View, { ...(Platform.OS === 'web' ? { dataSet: { historyKey: item.senderId + ':' + item.clientMessageId } } : {}), testID: highlighted ? 'focused-message' : undefined, style: highlighted || checked ? { backgroundColor: design.colors.accent + '20', borderRadius: 8 } : undefined, children: [start && design.screens?.chat?.showDates !== false && _jsx(Text, { testID: "messaging-date-separator", style: { alignSelf: 'center', fontSize: design.screens?.chat?.dateSize ?? 12, color: design.screens?.chat?.dateText ?? design.colors.secondary, backgroundColor: design.screens?.chat?.dateBackground ?? chatSurface(design.colors.background), borderRadius: 7, paddingHorizontal: 12, paddingVertical: 5, marginTop: 4, marginBottom: 10 }, children: date.toDateString() === new Date().toDateString() ? uiText("Today") : date.toLocaleDateString(uiLocale, { month: 'short', day: 'numeric' }) }), _jsx(View, { style: { paddingLeft: selection.length ? 32 : 0 }, pointerEvents: selection.length ? 'none' : 'auto', accessibilityElementsHidden: selection.length > 0, importantForAccessibility: selection.length ? 'no-hide-descendants' : 'auto', ...(Platform.OS === 'web' && selection.length ? { 'aria-hidden': true } : {}), children: Message ? _jsx(Message, { message: item }) : _jsx(MessagingBubbleItems, { message: item, pendingStatus: item.pendingStatus, ui: bubbleUI }) }), selectable && _jsx(Pressable, { accessibilityRole: "checkbox", accessibilityLabel: uiText('Select message: {message}', { message: item.text || item.media?.fileName || uiText(mediaNames[item.kind] || 'Message') }), accessibilityState: { checked }, onPress: toggle, style: { position: 'absolute', inset: 0, justifyContent: 'center' }, children: _jsx(View, { style: { width: 24, height: 24, borderRadius: 12, borderWidth: 1, borderColor: design.colors.accent, backgroundColor: checked ? design.colors.accent : design.colors.background, alignItems: 'center', justifyContent: 'center' }, children: checked && _jsx(MessageIcon, { name: "check", size: 16, color: "#ffffff" }) }) })] });
648
662
  });
649
663
  const conversationReadingPositions = new WeakMap();
650
664
  export function MessagingList() {
@@ -652,29 +666,25 @@ export function MessagingList() {
652
666
  const context = useMessagingUI();
653
667
  const { state, client, components, design, userId, selection, setSelection } = context;
654
668
  const Privacy = components?.PrivacyLayer ?? MessagingPrivacyLayer;
655
- const items = useMemo(() => orderChatMessages([...state.messages, ...state.pending.map(p => ({
669
+ const callTimeline = useContext(CallingTimeline);
670
+ const items = useMemo(() => orderChatMessages([...callTimeline.map(row => ({ id: 'call:' + row.id, clientMessageId: 'call:' + row.id, conversationId: state.conversationId, senderId: 'calling', kind: 'text', text: '', createdAt: new Date(row.createdAt).toISOString(), readAt: null, callingContent: row.content })), ...state.messages, ...state.pending.map(p => ({
656
671
  ...p.content, id: 'pending:' + p.clientMessageId, clientMessageId: p.clientMessageId, conversationId: state.conversationId, senderId: userId,
657
672
  createdAt: p.createdAt ?? new Date().toISOString(), readAt: null, pendingStatus: p.status,
658
- }))]).reverse(), [state.messages, state.pending, state.conversationId, userId]);
673
+ }))]).reverse(), [state.messages, state.pending, state.conversationId, userId, callTimeline]);
659
674
  const list = useRef(null);
660
675
  const historyInteraction = useRef({ conversationId: state.conversationId, dragged: false });
661
676
  if (historyInteraction.current.conversationId !== state.conversationId)
662
677
  historyInteraction.current = { conversationId: state.conversationId, dragged: false };
663
- const nearLatest = useRef(true), lastNewest = useRef(''), lastPending = useRef('');
664
- const latestFrame = useRef(null);
665
- const cancelLatestScroll = () => { if (latestFrame.current !== null)
666
- cancelAnimationFrame(latestFrame.current); latestFrame.current = null; };
678
+ const nearLatest = useRef(new HistoryFollow()).current, lastNewest = useRef(''), lastPending = useRef('');
679
+ const latestOffset = useRef(0);
680
+ const cancelLatestScroll = () => nearLatest.cancelLayout();
667
681
  const followLatestLayout = () => {
668
- if (!nearLatest.current || state.historyWindow || scrollTarget.current)
682
+ if (state.historyWindow || scrollTarget.current)
669
683
  return;
670
- cancelLatestScroll();
671
- latestFrame.current = requestAnimationFrame(() => {
672
- latestFrame.current = null;
673
- if (nearLatest.current && !scrollTarget.current)
674
- list.current?.scrollToOffset({ offset: 0, animated: false });
675
- });
684
+ nearLatest.layout(() => { if (!scrollTarget.current)
685
+ list.current?.scrollToOffset({ offset: 0, animated: false }); });
676
686
  };
677
- const interruptLatestScroll = () => { cancelLatestScroll(); historyInteraction.current.dragged = true; scrollTarget.current = null; };
687
+ const interruptLatestScroll = () => { nearLatest.begin(); historyInteraction.current.dragged = true; scrollTarget.current = null; };
678
688
  useLayoutEffect(() => () => cancelLatestScroll(), [state.conversationId]);
679
689
  const [away, setAway] = useState(false), [newMessages, setNewMessages] = useState(false);
680
690
  const [historyHeight, setHistoryHeight] = useState(0);
@@ -685,16 +695,17 @@ export function MessagingList() {
685
695
  const scrollingStarted = () => { if (scrollIdle.current)
686
696
  clearTimeout(scrollIdle.current); setScrolling(true); };
687
697
  const scrollingSettled = () => { if (scrollIdle.current)
688
- clearTimeout(scrollIdle.current); scrollIdle.current = setTimeout(() => { scrollIdle.current = null; setScrolling(false); }, 600); };
698
+ clearTimeout(scrollIdle.current); scrollIdle.current = setTimeout(() => { scrollIdle.current = null; const dragged = nearLatest.end(latestOffset.current); setScrolling(false); if (dragged)
699
+ followLatestLayout(); }, 600); };
689
700
  useEffect(() => { if (Platform.OS === 'web')
690
701
  return; const animation = Animated.timing(latestOpacity, { toValue: showLatest ? 1 : 0, duration: 200, useNativeDriver: true }); animation.start(); return () => animation.stop(); }, [showLatest, latestOpacity]);
691
702
  useEffect(() => { setScrolling(false); return () => { if (scrollIdle.current)
692
703
  clearTimeout(scrollIdle.current); }; }, [state.conversationId]);
693
704
  const jumpToLatest = (animated = true) => { if (state.historyWindow) {
694
- void client.goToLatest().then(() => { list.current?.scrollToOffset({ offset: 0, animated }); nearLatest.current = true; setAway(false); setNewMessages(false); }).catch(() => { });
705
+ void client.goToLatest().then(() => { list.current?.scrollToOffset({ offset: 0, animated }); nearLatest.reset(); setAway(false); setNewMessages(false); }).catch(() => { });
695
706
  return;
696
- } list.current?.scrollToOffset({ offset: 0, animated }); nearLatest.current = true; setAway(false); setNewMessages(false); };
697
- useEffect(() => { nearLatest.current = true; lastNewest.current = ''; lastPending.current = ''; setAway(false); setNewMessages(false); list.current?.scrollToOffset({ offset: 0, animated: false }); }, [state.conversationId]);
707
+ } list.current?.scrollToOffset({ offset: 0, animated }); nearLatest.reset(); setAway(false); setNewMessages(false); };
708
+ useEffect(() => { nearLatest.reset(); lastNewest.current = ''; lastPending.current = ''; setAway(false); setNewMessages(false); list.current?.scrollToOffset({ offset: 0, animated: false }); }, [state.conversationId]);
698
709
  const [highlight, setHighlight] = useState(null);
699
710
  const scrollTarget = useRef(null);
700
711
  useEffect(() => {
@@ -703,7 +714,7 @@ export function MessagingList() {
703
714
  const index = items.findIndex(m => m.id === state.focus.messageId);
704
715
  if (index < 0)
705
716
  return;
706
- nearLatest.current = false;
717
+ nearLatest.pause();
707
718
  setAway(true);
708
719
  setHighlight(state.focus.messageId);
709
720
  scrollTarget.current = { index, attempts: 0 };
@@ -732,7 +743,7 @@ export function MessagingList() {
732
743
  restoredReading.current = readingKey;
733
744
  const anchor = conversationReadingPositions.get(client)?.get(readingKey);
734
745
  if (anchor) {
735
- nearLatest.current = false;
746
+ nearLatest.pause();
736
747
  setAway(true);
737
748
  void client.focusMessage(anchor).catch(() => { conversationReadingPositions.get(client)?.delete(readingKey); });
738
749
  }
@@ -815,50 +826,55 @@ export function MessagingList() {
815
826
  if (!ids.has(key))
816
827
  rowUIs.current.delete(key); }, [items]);
817
828
  const renderHistoryItem = useCallback(({ item, index }) => {
818
- const previous = items[index + 1], next = items[index - 1], key = item.senderId + ':' + item.clientMessageId;
829
+ if (item.callingContent)
830
+ return _jsx(View, { ...(Platform.OS === 'web' ? { dataSet: { historyKey: item.clientMessageId } } : {}), style: { paddingVertical: 4 }, children: item.callingContent });
831
+ const previous = items[index + 1]?.callingContent ? undefined : items[index + 1], next = items[index - 1]?.callingContent ? undefined : items[index - 1], key = item.senderId + ':' + item.clientMessageId;
819
832
  const bubbleUI = selectBubbleUI(context, { message: item, previousMessage: previous, nextMessage: next }, rowUIs.current.get(key) ?? null);
820
833
  rowUIs.current.set(key, bubbleUI);
821
834
  return _jsx(MessagingHistoryRow, { item: item, previous: previous, next: next, highlighted: highlight === item.id, selection: selection, setSelection: setSelection, design: design, Message: components?.Message, bubbleUI: bubbleUI });
822
835
  }, [context, items, highlight, selection, setSelection, design, components?.Message]);
823
- return (_jsxs(View, { style: { flex: 1, minHeight: 0 }, children: [_jsx(Privacy, { enabled: !!context.extrasState?.privacyLens, background: design.colors.background, children: _jsx(FlatList, { ref: list, testID: "messaging-history", onLayout: event => { setHistoryHeight(event.nativeEvent.layout.height); const target = scrollTarget.current; if (target)
824
- requestAnimationFrame(() => { if (scrollTarget.current === target)
825
- list.current?.scrollToIndex({ index: target.index, viewPosition: .5, animated: false }); }); }, maintainVisibleContentPosition: highlight ? undefined : { minIndexForVisible: 0, ...(!state.historyWindow ? { autoscrollToTopThreshold: 80 } : {}) }, onContentSizeChange: () => { const target = scrollTarget.current; if (target)
826
- requestAnimationFrame(() => { if (scrollTarget.current === target)
827
- list.current?.scrollToIndex({ index: target.index, viewPosition: .5, animated: false }); });
828
- else
829
- followLatestLayout(); },
830
- // Keep nearby history ready without mounting most of a long conversation.
831
- // Smaller batches leave the JS thread available for incoming messages,
832
- // gestures and receipt updates while the user scrolls.
833
- initialNumToRender: 12, maxToRenderPerBatch: 8, windowSize: 5, onScrollToIndexFailed: info => {
834
- const target = scrollTarget.current;
835
- if (!target || target.retryTimer || target.attempts >= 20)
836
- return;
837
- target.attempts++;
838
- // A distant cell may need several native layout batches. Coalesce
839
- // layout callbacks so they cannot exhaust retries before those batches.
840
- target.retryTimer = setTimeout(() => { target.retryTimer = undefined; if (scrollTarget.current === target)
841
- list.current?.scrollToIndex({ index: target.index, viewPosition: .5, animated: false }); }, 150);
842
- list.current?.scrollToOffset({ offset: info.averageItemLength * info.index, animated: false });
843
- }, onScrollBeginDrag: () => { interruptLatestScroll(); scrollingStarted(); }, ...(Platform.OS === 'web' ? {
844
- // Browser wheel/keyboard/scrollbar input does not emit native drag events.
845
- onWheel: interruptLatestScroll,
846
- onPointerDown: interruptLatestScroll,
847
- onKeyDown: (event) => { if (['ArrowUp', 'ArrowDown', 'PageUp', 'PageDown', 'Home', 'End', ' '].includes(event.key))
848
- interruptLatestScroll(); },
849
- } : {}), onScrollEndDrag: scrollingSettled, onMomentumScrollBegin: scrollingStarted, onMomentumScrollEnd: scrollingSettled, onScroll: event => { scrollingStarted(); scrollingSettled(); if (latestFrame.current !== null)
850
- return; const near = event.nativeEvent.contentOffset.y < 80; nearLatest.current = near; setAway(!near); if (near)
851
- setNewMessages(false); }, scrollEventThrottle: 32, data: items, inverted: true, keyExtractor: (m) => m.senderId + ':' + m.clientMessageId, style: { flex: 1 }, keyboardShouldPersistTaps: "handled", contentContainerStyle: { paddingHorizontal: 12, paddingVertical: 10, paddingTop: context.extrasState?.privacyLens ? privacyReadingStripHeight + 10 : 10, flexGrow: 1, justifyContent: context.extrasState?.privacyLens ? "flex-start" : "flex-end" }, onViewableItemsChanged: onVisible, viewabilityConfig: {
852
- itemVisiblePercentThreshold: 50,
853
- minimumViewTime: 500,
854
- }, renderItem: renderHistoryItem, onEndReached: () => {
855
- // Native lists can report their end before the first content layout.
856
- // Do not load successive older pages while the opening screen settles.
857
- // Short histories still expose the explicit “Load earlier messages”.
858
- if (historyInteraction.current.dragged && state.hasMore && !state.loading && !state.historyError) {
859
- void client.loadOlder().catch(() => { });
860
- }
861
- }, onEndReachedThreshold: 0.2, ListHeaderComponent: _jsxs(_Fragment, { children: [(state.heldMessages ?? []).map(item => _jsxs(View, { testID: "held-message", style: { padding: 12, marginVertical: 4, borderWidth: 1, borderColor: design.colors.secondary, borderRadius: 8 }, children: [_jsx(Text, { style: { color: design.colors.foreground }, children: item.content.text ?? item.content.media?.fileName ?? 'Message' }), _jsx(Text, { accessibilityLiveRegion: "polite", style: { color: design.colors.secondary, fontSize: 12, marginTop: 4 }, children: uiText(item.state === 'pending' ? 'Waiting for review — not delivered' : item.state === 'approved' ? 'Approved — waiting for delivery' : item.state === 'rejected' ? 'Not approved — not delivered' : 'Review expired — not delivered') })] }, item.id)), state.historyWindow && state.hasNewer ? _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText("Load newer messages"), disabled: state.loading, onPress: () => void client.loadNewer().catch(() => { }), style: { padding: 10, minHeight: 44, alignItems: 'center' }, children: _jsx(Text, { style: { color: design.colors.accent }, children: uiText("Load newer messages") }) }) : null] }), ListFooterComponent: _jsxs(_Fragment, { children: [state.messages.length > 0 && (state.loading || state.historyError || state.hasMore) ? _jsx(View, { style: { padding: 10, minHeight: 64, justifyContent: 'center', alignItems: 'center' }, children: state.loading ? _jsx(ActivityIndicator, { accessibilityLabel: uiText("Loading earlier messages"), color: design.colors.accent }) : _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: state.historyError ? uiText("Retry earlier messages") : uiText("Load earlier messages"), onPress: () => void client.loadOlder().catch(() => { }), style: { minHeight: 44, justifyContent: 'center' }, children: _jsx(Text, { style: { color: design.colors.accent }, children: state.historyError ? uiText("Earlier messages could not load. Retry") : uiText("Load earlier messages") }) }) }) : null, context.extrasState?.privacyLens && _jsx(View, { testID: "privacy-history-spacer", style: { height: Math.max(0, historyHeight - privacyReadingStripHeight) } })] }), ListEmptyComponent: state.loading ? _jsx(MessagingLoadingMessages, { color: design.colors.secondary }, state.conversationId) : state.error ? null : _jsx(Text, { style: { color: design.colors.secondary }, children: design.labels.empty }) }, state.conversationId + (context.extrasState?.privacyLens ? "privacy-reading" : "regular-history")) }), (away || state.historyWindow) && _jsx(Animated.View, { testID: "latest-message-control", pointerEvents: showLatest ? 'auto' : 'none', accessibilityElementsHidden: !showLatest, importantForAccessibility: showLatest ? 'auto' : 'no-hide-descendants', ...(Platform.OS === 'web' ? { 'aria-hidden': !showLatest } : {}), style: { position: 'absolute', left: '50%', marginLeft: -22, bottom: 8, opacity: Platform.OS === 'web' ? (showLatest ? 1 : 0) : latestOpacity, ...(Platform.OS === 'web' ? { transitionProperty: 'opacity', transitionDuration: '200ms' } : {}) }, children: _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: newMessages ? uiText("New messages. Go to latest") : uiText("Go to latest message"), disabled: !showLatest, onPress: () => jumpToLatest(), style: { width: 44, height: 44, borderRadius: 22, borderWidth: 1.5, borderColor: design.colors.accent, backgroundColor: chatSurface(design.colors.background), justifyContent: 'center', alignItems: 'center' }, children: _jsx(MessageIcon, { name: "arrow-down", color: design.colors.accent, size: 26 }) }) }), _jsx(MessageSelection, {})] }));
836
+ return (_jsxs(View, { style: { flex: 1, minHeight: 0 }, children: [_jsx(Privacy, { enabled: !!context.extrasState?.privacyLens, background: design.colors.background, children: _jsx(HistoryScrollAnchor, { historyKey: state.conversationId + ':' + (state.focus?.messageId ?? ''), following: nearLatest, node: () => Platform.OS === 'web' ? list.current?.getScrollableNode() ?? null : null, children: _jsx(FlatList, { ref: list, testID: "messaging-history", onLayout: event => { setHistoryHeight(event.nativeEvent.layout.height); const target = scrollTarget.current; if (target)
837
+ requestAnimationFrame(() => { if (scrollTarget.current === target)
838
+ list.current?.scrollToIndex({ index: target.index, viewPosition: .5, animated: false }); }); }, maintainVisibleContentPosition: highlight ? undefined : { minIndexForVisible: 0, ...(!state.historyWindow ? { autoscrollToTopThreshold: 80 } : {}) }, onContentSizeChange: () => { const target = scrollTarget.current; if (target)
839
+ requestAnimationFrame(() => { if (scrollTarget.current === target)
840
+ list.current?.scrollToIndex({ index: target.index, viewPosition: .5, animated: false }); });
841
+ else
842
+ followLatestLayout(); },
843
+ // Keep nearby history ready without mounting most of a long conversation.
844
+ // Smaller batches leave the JS thread available for incoming messages,
845
+ // gestures and receipt updates while the user scrolls.
846
+ initialNumToRender: 12, maxToRenderPerBatch: 8, windowSize: 5, onScrollToIndexFailed: info => {
847
+ const target = scrollTarget.current;
848
+ if (!target || target.retryTimer || target.attempts >= 20)
849
+ return;
850
+ target.attempts++;
851
+ // A distant cell may need several native layout batches. Coalesce
852
+ // layout callbacks so they cannot exhaust retries before those batches.
853
+ target.retryTimer = setTimeout(() => { target.retryTimer = undefined; if (scrollTarget.current === target)
854
+ list.current?.scrollToIndex({ index: target.index, viewPosition: .5, animated: false }); }, 150);
855
+ list.current?.scrollToOffset({ offset: info.averageItemLength * info.index, animated: false });
856
+ }, onScrollBeginDrag: () => { interruptLatestScroll(); scrollingStarted(); }, ...(Platform.OS === 'web' ? {
857
+ // Browser wheel/keyboard/scrollbar input does not emit native drag events.
858
+ onWheel: () => { interruptLatestScroll(); scrollingSettled(); },
859
+ onPointerDown: interruptLatestScroll,
860
+ onPointerUp: scrollingSettled,
861
+ onPointerCancel: scrollingSettled,
862
+ onKeyDown: (event) => { if (['ArrowUp', 'ArrowDown', 'PageUp', 'PageDown', 'Home', 'End', ' '].includes(event.key)) {
863
+ interruptLatestScroll();
864
+ scrollingSettled();
865
+ } },
866
+ } : {}), onScrollEndDrag: scrollingSettled, onMomentumScrollBegin: () => { nearLatest.begin(); scrollingStarted(); }, onMomentumScrollEnd: scrollingSettled, onScroll: event => { scrollingStarted(); scrollingSettled(); latestOffset.current = event.nativeEvent.contentOffset.y; const near = nearLatest.observe(latestOffset.current); setAway(!near); if (near)
867
+ setNewMessages(false); }, scrollEventThrottle: 32, data: items, inverted: true, keyExtractor: (m) => m.senderId + ':' + m.clientMessageId, style: { flex: 1 }, keyboardShouldPersistTaps: "handled", contentContainerStyle: { paddingHorizontal: 12, paddingVertical: 10, paddingTop: context.extrasState?.privacyLens ? privacyReadingStripHeight + 10 : 10, flexGrow: 1, justifyContent: context.extrasState?.privacyLens ? "flex-start" : "flex-end" }, onViewableItemsChanged: onVisible, viewabilityConfig: {
868
+ itemVisiblePercentThreshold: 50,
869
+ minimumViewTime: 500,
870
+ }, renderItem: renderHistoryItem, onEndReached: () => {
871
+ // Native lists can report their end before the first content layout.
872
+ // Do not load successive older pages while the opening screen settles.
873
+ // Short histories still expose the explicit “Load earlier messages”.
874
+ if (historyInteraction.current.dragged && state.hasMore && !state.loading && !state.historyError) {
875
+ void client.loadOlder().catch(() => { });
876
+ }
877
+ }, onEndReachedThreshold: 0.2, ListHeaderComponent: _jsxs(_Fragment, { children: [(state.heldMessages ?? []).map(item => _jsxs(View, { testID: "held-message", style: { padding: 12, marginVertical: 4, borderWidth: 1, borderColor: design.colors.secondary, borderRadius: 8 }, children: [_jsx(Text, { style: { color: design.colors.foreground }, children: item.content.text ?? item.content.media?.fileName ?? 'Message' }), _jsx(Text, { accessibilityLiveRegion: "polite", style: { color: design.colors.secondary, fontSize: 12, marginTop: 4 }, children: uiText(item.state === 'pending' ? 'Waiting for review — not delivered' : item.state === 'approved' ? 'Approved — waiting for delivery' : item.state === 'rejected' ? 'Not approved — not delivered' : 'Review expired — not delivered') })] }, item.id)), state.historyWindow && state.hasNewer ? _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText("Load newer messages"), disabled: state.loading, onPress: () => void client.loadNewer().catch(() => { }), style: { padding: 10, minHeight: 44, alignItems: 'center' }, children: _jsx(Text, { style: { color: design.colors.accent }, children: uiText("Load newer messages") }) }) : null] }), ListFooterComponent: _jsxs(_Fragment, { children: [state.messages.length > 0 && (state.loading || state.historyError || state.hasMore) ? _jsx(View, { style: { padding: 10, minHeight: 64, justifyContent: 'center', alignItems: 'center' }, children: state.loading ? _jsx(ActivityIndicator, { accessibilityLabel: uiText("Loading earlier messages"), color: design.colors.accent }) : _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: state.historyError ? uiText("Retry earlier messages") : uiText("Load earlier messages"), onPress: () => void client.loadOlder().catch(() => { }), style: { minHeight: 44, justifyContent: 'center' }, children: _jsx(Text, { style: { color: design.colors.accent }, children: state.historyError ? uiText("Earlier messages could not load. Retry") : uiText("Load earlier messages") }) }) }) : null, context.extrasState?.privacyLens && _jsx(View, { testID: "privacy-history-spacer", style: { height: Math.max(0, historyHeight - privacyReadingStripHeight) } })] }), ListEmptyComponent: state.loading ? _jsx(MessagingLoadingMessages, { color: design.colors.secondary }, state.conversationId) : state.error ? null : _jsx(Text, { style: { color: design.colors.secondary }, children: design.labels.empty }) }, state.conversationId + (context.extrasState?.privacyLens ? "privacy-reading" : "regular-history")) }) }), (away || state.historyWindow) && _jsx(Animated.View, { testID: "latest-message-control", pointerEvents: showLatest ? 'auto' : 'none', accessibilityElementsHidden: !showLatest, importantForAccessibility: showLatest ? 'auto' : 'no-hide-descendants', ...(Platform.OS === 'web' ? { 'aria-hidden': !showLatest } : {}), style: { position: 'absolute', left: '50%', marginLeft: -22, bottom: 8, opacity: Platform.OS === 'web' ? (showLatest ? 1 : 0) : latestOpacity, ...(Platform.OS === 'web' ? { transitionProperty: 'opacity', transitionDuration: '200ms' } : {}) }, children: _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: newMessages ? uiText("New messages. Go to latest") : uiText("Go to latest message"), disabled: !showLatest, onPress: () => jumpToLatest(), style: { width: 44, height: 44, borderRadius: 22, borderWidth: 1.5, borderColor: design.colors.accent, backgroundColor: chatSurface(design.colors.background), justifyContent: 'center', alignItems: 'center' }, children: _jsx(MessageIcon, { name: "arrow-down", color: design.colors.accent, size: 26 }) }) }), _jsx(MessageSelection, {})] }));
862
878
  }
863
879
  /** One horizontal media row on phones and in the browser preview. */
864
880
  function AttachmentStrip({ children, label, height, recent = false }) {
@@ -1226,7 +1242,7 @@ export function MessagingComposer() {
1226
1242
  return (_jsxs(View, { testID: "messaging-composer", style: { paddingStart: 8, paddingEnd: 0, paddingVertical: 4, gap: 8, backgroundColor: design.composer?.background ?? c.background }, children: [mentionSuggestions.length > 0 && _jsx(ScrollView, { keyboardShouldPersistTaps: "handled", style: { maxHeight: 144 }, children: mentionSuggestions.map(id => _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText('Mention {name}', { name: participants[id].name }), onPress: () => chooseMention(id), style: { minHeight: 44, paddingHorizontal: 12, justifyContent: 'center', borderBottomWidth: .5, borderBottomColor: c.secondary + '30' }, children: _jsxs(Text, { style: { color: c.accent, fontSize: 16 }, children: ["@", participants[id].name] }) }, id)) }), mentionQuery !== undefined && !!mentionError && _jsx(Text, { style: { color: c.secondary, fontSize: 13 }, children: mentionError }), editing && _jsxs(View, { style: { flexDirection: 'row', alignItems: 'center', gap: 8 }, children: [_jsxs(Text, { numberOfLines: 1, style: { flex: 1, color: c.secondary }, children: [uiText("Editing:"), editing.text || editing.media?.fileName] }), _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText("Cancel editing"), disabled: busy, onPress: () => setEditing(null), style: { minHeight: 36, justifyContent: 'center' }, children: _jsx(Text, { style: { color: c.accent }, children: uiText("Cancel") }) })] }), !editing && reply && (_jsxs(View, { testID: "composer-quote", style: { flexDirection: "row", gap: 8 }, children: [_jsx(View, { style: { flex: 1 }, children: _jsx(QuotedPreview, { message: reply, ink: c.secondary }) }), _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText("Cancel quote"), onPress: () => setReply(null), children: _jsx(Text, { style: { color: c.foreground }, children: uiText("Cancel") }) })] })), state.settings?.history?.mode === 'last_two' && _jsx(Text, { style: { color: c.secondary, fontSize: 11, textAlign: 'center' }, children: uiText("Only the latest two messages are kept.") }), editing ? _jsxs(_Fragment, { children: [renderAttachments(), renderTextComposer()] }) : features?.voice ? _jsx(VoiceComposer, { appearance: design, maxSeconds: state.settings?.voice?.maxDurationSeconds ?? 60, busy: busy, onRecord: () => { Keyboard.dismiss(); void pick('voice'); }, renderAttachments: renderAttachments, renderTextComposer: features?.text || selected.length ? renderTextComposer : undefined, actions: _jsx(_Fragment, { children: (camera || library.image || library.video || library.document || !editing && (features?.poll || weatherAllowed)) && _jsx(Pressable, { ref: attachmentButton, accessibilityRole: "button", accessibilityLabel: uiText("Attach"), accessibilityState: { expanded: attachmentsOpen }, disabled: busy, onPress: () => setAttachmentsOpen(!attachmentsOpen), style: { width: 44, height: 44, alignItems: 'center', justifyContent: 'center' }, children: _jsx(MessageIcon, { name: attachmentsOpen ? 'close' : 'plus', color: c.foreground, size: 25 }) }) }) }) : _jsxs(_Fragment, { children: [renderAttachments(), renderTextComposer()] }), attachmentsOpen && _jsx(AttachmentMenu, { anchor: attachmentButton, accent: c.accent, onClose: () => setAttachmentsOpen(false), actions: attachmentActions }), scheduleOpen && _jsx(ScheduleTimePicker, { initial: scheduleAttempt.current?.time, retryAt: scheduleError ? scheduleAttempt.current?.time : undefined, accent: c.accent, busy: busy, error: scheduleError, onSave: time => void schedule(time), onClose: () => setScheduleOpen(false) }), pollOpen && features?.poll && _jsx(PollComposer, { yesNo: state.conversation?.kind !== 'group', appearance: design, onSend: poll => submit({ kind: 'poll', poll }), onCancel: () => setPollOpen(false) }), error && (_jsx(Text, { accessibilityRole: "alert", style: { color: c.foreground }, children: error }))] }));
1227
1243
  }
1228
1244
  /** Account navigation. Mount in the inbox/app toolbar, never in a contact menu. */
1229
- export function MessagingAccountMenu({ inbox, onNewGroup, onMaps, onPublicRooms } = {}) {
1245
+ export function MessagingAccountMenu({ inbox, onNewGroup, onMaps, onPublicRooms, onVoicemail } = {}) {
1230
1246
  const { text } = useRobonoLocale(), { client, design, setSavedOpen, account, companyName } = useMessagingUI();
1231
1247
  const [open, setOpen] = useState(false), [accountOpen, setAccountOpen] = useState(false), [page, setPage] = useState(null), pending = useRef(null);
1232
1248
  const menu = messagingMenuColors(design, 'friends'), items = design.menus?.friends?.items, layout = messagingMenuLayout(design.menus?.friends);
@@ -1240,6 +1256,8 @@ export function MessagingAccountMenu({ inbox, onNewGroup, onMaps, onPublicRooms
1240
1256
  if (key === 'language' && client.hasSavedMessages() && items?.saved !== false)
1241
1257
  rows.push({ key: 'saved', label: 'Saved', icon: 'bookmark-outline' });
1242
1258
  }
1259
+ if (onVoicemail)
1260
+ rows.push({ key: 'voicemail', label: 'Voicemail', icon: 'mic-outline' });
1243
1261
  if (onMaps && items?.maps !== false)
1244
1262
  rows.push({ key: 'maps', label: 'Maps', icon: 'location' });
1245
1263
  if (onPublicRooms && items?.publicGroups !== false)
@@ -1258,6 +1276,8 @@ export function MessagingAccountMenu({ inbox, onNewGroup, onMaps, onPublicRooms
1258
1276
  onMaps?.();
1259
1277
  else if (next === 'rooms')
1260
1278
  onPublicRooms?.();
1279
+ else if (next === 'voicemail')
1280
+ onVoicemail?.();
1261
1281
  else if (next === 'account')
1262
1282
  setAccountOpen(true);
1263
1283
  else if (next === 'linkedApps' && account?.onLinkedApps)
@@ -0,0 +1,7 @@
1
+ import React, { type ReactNode } from 'react';
2
+ /** Use the same formatter as the surrounding Messenger, including host locale. */
3
+ export declare function MessagingTimeFormatProvider({ format, children }: {
4
+ format: (value: string) => string;
5
+ children: ReactNode;
6
+ }): React.JSX.Element;
7
+ export declare function useMessagingTimeFormat(): (value: string) => string;
@@ -0,0 +1,17 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { createContext, useContext, useMemo } from 'react';
3
+ import { useRobonoLocale } from './localization.js';
4
+ const TimeFormat = createContext(null);
5
+ const formatters = new Map();
6
+ /** Use the same formatter as the surrounding Messenger, including host locale. */
7
+ export function MessagingTimeFormatProvider({ format, children }) { return _jsx(TimeFormat.Provider, { value: format, children: children }); }
8
+ export function useMessagingTimeFormat() {
9
+ const inherited = useContext(TimeFormat), { locale } = useRobonoLocale();
10
+ const fallback = useMemo(() => (value) => { const date = new Date(value), key = locale + ':' + date.getTimezoneOffset(); let formatter = formatters.get(key); if (!formatter) {
11
+ formatter = new Intl.DateTimeFormat(locale, { hour: 'numeric', minute: '2-digit' });
12
+ if (formatters.size >= 8)
13
+ formatters.clear();
14
+ formatters.set(key, formatter);
15
+ } return formatter.format(date); }, [locale]);
16
+ return inherited ?? fallback;
17
+ }
@@ -2,7 +2,10 @@ import React from 'react';
2
2
  import { type VideoViewProps, type VideoPlayer } from 'expo-video';
3
3
  /** Shared by Robono Messenger and the SDK. A decoded frame includes the camera's
4
4
  * rotation; the encoded track's natural width/height does not necessarily do so. */
5
- export declare function MessengerVideoView({ player, posterUri, ...props }: Omit<VideoViewProps, 'player' | 'contentFit' | 'fullscreenOptions'> & {
5
+ export declare function MessengerVideoView({ player, sourceUri, posterUri, allowFullscreen, onDimensions, ...props }: Omit<VideoViewProps, 'player' | 'contentFit' | 'fullscreenOptions'> & {
6
6
  player: VideoPlayer;
7
+ sourceUri?: string;
7
8
  posterUri?: string | null;
9
+ allowFullscreen?: boolean;
10
+ onDimensions?: (width: number, height: number) => void;
8
11
  }): React.JSX.Element;
@@ -1,16 +1,27 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useEffect, useState } from 'react';
3
- import { Image } from 'react-native';
3
+ import { Image, Platform } from 'react-native';
4
+ import { readLocalVideoOrientation } from './expo-video-orientation.js';
4
5
  import { VideoView } from 'expo-video';
5
6
  /** Shared by Robono Messenger and the SDK. A decoded frame includes the camera's
6
7
  * rotation; the encoded track's natural width/height does not necessarily do so. */
7
- export function MessengerVideoView({ player, posterUri, ...props }) {
8
+ export function MessengerVideoView({ player, sourceUri, posterUri, allowFullscreen = true, onDimensions, ...props }) {
9
+ const [mirrorVideoSurface, setMirrorVideoSurface] = useState(false);
10
+ useEffect(() => {
11
+ let alive = true;
12
+ setMirrorVideoSurface(false);
13
+ if (Platform.OS === 'android' && sourceUri)
14
+ void readLocalVideoOrientation(sourceUri).then(track => { if (alive)
15
+ setMirrorVideoSurface(!!track?.mirrored); }).catch(() => { });
16
+ return () => { alive = false; };
17
+ }, [sourceUri]);
18
+ const displayProps = Platform.OS === 'android' ? { mirrorVideoSurface } : {};
8
19
  const [orientation, setOrientation] = useState('default');
9
20
  useEffect(() => {
10
21
  let alive = true, pending = false, resolved = false;
11
22
  setOrientation('default');
12
23
  const accept = (width, height) => { if (!alive || width <= 0 || height <= 0)
13
- return; resolved = true; setOrientation(width > height ? 'landscape' : 'portrait'); };
24
+ return; resolved = true; onDimensions?.(width, height); setOrientation(width > height ? 'landscape' : 'portrait'); };
14
25
  const decode = async () => {
15
26
  if (!alive || pending || resolved || player.status !== 'readyToPlay' || typeof player.generateThumbnailsAsync !== 'function')
16
27
  return;
@@ -42,5 +53,5 @@ export function MessengerVideoView({ player, posterUri, ...props }) {
42
53
  void decode(); });
43
54
  return () => { alive = false; status.remove(); source.remove(); };
44
55
  }, [player, posterUri]);
45
- return _jsx(VideoView, { nativeControls: true, ...props, player: player, contentFit: "contain", fullscreenOptions: { enable: true, orientation } });
56
+ return _jsx(VideoView, { nativeControls: true, ...props, ...displayProps, player: player, surfaceType: !allowFullscreen || Platform.OS === 'android' && mirrorVideoSurface ? 'textureView' : props.surfaceType, style: [!allowFullscreen && { overflow: 'hidden' }, props.style], contentFit: "contain", fullscreenOptions: { enable: allowFullscreen, orientation } });
46
57
  }
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ /** Transient recording feedback never participates in composer measurement. */
3
+ export declare function RecordingNotice({ message }: {
4
+ message?: string | null;
5
+ }): React.JSX.Element | null;
@@ -0,0 +1,13 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useEffect, useState } from 'react';
3
+ import { View } from 'react-native';
4
+ import { Text } from './typography.js';
5
+ /** Transient recording feedback never participates in composer measurement. */
6
+ export function RecordingNotice({ message }) {
7
+ const [visible, setVisible] = useState(false);
8
+ useEffect(() => { setVisible(!!message); if (!message)
9
+ return; const timer = setTimeout(() => setVisible(false), 3000); return () => clearTimeout(timer); }, [message]);
10
+ if (!visible || !message)
11
+ return null;
12
+ return _jsx(View, { pointerEvents: "none", testID: "recording-notice", style: { position: 'absolute', bottom: '100%', left: 8, right: 8, marginBottom: 8, zIndex: 100, elevation: 12, alignItems: 'center' }, children: _jsx(View, { style: { maxWidth: 420, borderRadius: 10, backgroundColor: '#202124', paddingHorizontal: 14, paddingVertical: 10 }, children: _jsx(Text, { accessibilityRole: "alert", accessibilityLiveRegion: "polite", style: { color: '#fff', fontSize: 13, textAlign: 'center' }, children: message }) }) });
13
+ }
@@ -25,5 +25,6 @@ export declare function useQuoteGesture(enabled: boolean, outgoing: boolean, quo
25
25
  transitionTimingFunction?: undefined;
26
26
  };
27
27
  handlers: import("react-native").GestureResponderHandlers;
28
+ cancel: () => void;
28
29
  suppressPress: () => boolean;
29
30
  };
@@ -155,5 +155,6 @@ export function useQuoteGesture(enabled, outgoing, quote, details, onQuoteReady)
155
155
  revealWebStyle: Platform.OS === 'web' ? { transitionProperty: 'opacity', transitionDuration: webDragging ? '0ms' : '150ms' } : {},
156
156
  webStyle: Platform.OS === 'web' ? { transitionProperty: 'transform', transitionDuration: webDragging ? '0ms' : '150ms', transitionTimingFunction: 'cubic-bezier(0.215,0.61,0.355,1)' } : {},
157
157
  handlers: Platform.OS === 'web' ? {} : responder.panHandlers,
158
+ cancel: () => { pointer.current = null; quoteReady.current = false; suppressUntil.current = Date.now() + 400; reset(); },
158
159
  suppressPress: () => Date.now() < suppressUntil.current };
159
160
  }
@@ -0,0 +1,7 @@
1
+ import React, { type ReactNode } from 'react';
2
+ /** Metadata stays inside the thumbnail, shared by regular and voicemail video. */
3
+ export declare function VideoMessageBadge({ durationMs, label, time }: {
4
+ durationMs?: number | null;
5
+ label?: ReactNode;
6
+ time?: ReactNode;
7
+ }): React.JSX.Element;
@@ -0,0 +1,8 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { View } from 'react-native';
3
+ import { Text } from './typography.js';
4
+ import { duration } from './icons.js';
5
+ /** Metadata stays inside the thumbnail, shared by regular and voicemail video. */
6
+ export function VideoMessageBadge({ durationMs, label, time }) {
7
+ return _jsxs(View, { pointerEvents: "none", testID: "video-message-badge", style: { position: 'absolute', left: 6, right: 6, bottom: 6, alignItems: 'flex-end', gap: 2 }, children: [time, _jsxs(View, { style: { maxWidth: '100%', flexDirection: 'row', alignItems: 'center', gap: 6, borderRadius: 4, paddingHorizontal: 5, paddingVertical: 2, backgroundColor: '#0009' }, children: [label, _jsx(Text, { testID: "video-message-duration", style: { color: '#fff', fontSize: 11, fontVariant: ['tabular-nums'] }, children: duration(durationMs ?? 0) })] })] });
8
+ }
@@ -0,0 +1,13 @@
1
+ /** Read only ISO-BMFF headers, skipping media payloads. Matrix belongs to the
2
+ * video track; audio tracks have zero display dimensions. */
3
+ export declare function readVideoOrientation(read: (offset: number, length: number) => Promise<Uint8Array>, length: number): Promise<{
4
+ rotation: number;
5
+ width: number;
6
+ height: number;
7
+ mirrored: boolean;
8
+ } | undefined>;
9
+ export declare function thumbnailRotation(track: {
10
+ rotation: number;
11
+ width: number;
12
+ height: number;
13
+ } | undefined, width: number, height: number): 0 | 90 | 270;
@@ -0,0 +1,58 @@
1
+ /** Read only ISO-BMFF headers, skipping media payloads. Matrix belongs to the
2
+ * video track; audio tracks have zero display dimensions. */
3
+ export async function readVideoOrientation(read, length) {
4
+ let visited = 0;
5
+ const scan = async (start, end, depth) => {
6
+ if (depth > 3)
7
+ return;
8
+ for (let offset = start; offset + 8 <= end && visited++ < 256;) {
9
+ const header = await read(offset, 16);
10
+ if (header.length < 8)
11
+ return;
12
+ const h = new DataView(header.buffer, header.byteOffset, header.byteLength);
13
+ let size = h.getUint32(0), head = 8;
14
+ const type = String.fromCharCode(...header.slice(4, 8));
15
+ if (size === 1) {
16
+ if (header.length < 16)
17
+ return;
18
+ size = h.getUint32(8) * 4294967296 + h.getUint32(12);
19
+ head = 16;
20
+ }
21
+ else if (size === 0)
22
+ size = end - offset;
23
+ if (!Number.isSafeInteger(size) || size < head || offset + size > end)
24
+ return;
25
+ if (type === 'moov' || type === 'trak') {
26
+ const result = await scan(offset + head, offset + size, depth + 1);
27
+ if (result)
28
+ return result;
29
+ }
30
+ if (type === 'tkhd') {
31
+ const bytes = await read(offset + head, Math.min(100, size - head));
32
+ const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength), matrix = bytes[0] === 1 ? 52 : 40;
33
+ if (bytes.length >= matrix + 44) {
34
+ const width = view.getUint32(matrix + 36) / 65536, height = view.getUint32(matrix + 40) / 65536;
35
+ if (width > 0 && height > 0) {
36
+ const a = view.getInt32(matrix) / 65536, b = view.getInt32(matrix + 4) / 65536;
37
+ const c = view.getInt32(matrix + 12) / 65536, d = view.getInt32(matrix + 16) / 65536;
38
+ const mirrored = a * d - b * c < 0;
39
+ const rotation = (Math.round(Math.atan2(b, mirrored ? d : a) * 180 / Math.PI) + 360) % 360;
40
+ return { rotation, width, height, mirrored };
41
+ }
42
+ }
43
+ }
44
+ offset += size;
45
+ }
46
+ };
47
+ return scan(0, length, 0);
48
+ }
49
+ export function thumbnailRotation(track, width, height) {
50
+ if (!track || !width || !height)
51
+ return 0;
52
+ const r = track.rotation;
53
+ if (r !== 90 && r !== 270)
54
+ return 0;
55
+ const raw = track.width / track.height, actual = width / height;
56
+ // Some decoders apply the matrix already. Never rotate those frames twice.
57
+ return Math.abs(actual - raw) < Math.abs(actual - 1 / raw) ? r : 0;
58
+ }
@@ -17,12 +17,14 @@ export interface VoiceComposerProps {
17
17
  hasVoice: boolean;
18
18
  blocked: boolean;
19
19
  }) => ReactNode;
20
+ onRecordAgain?: () => void;
21
+ sendWhileRecording?: boolean;
20
22
  onStop?: () => void;
21
23
  onSend?: () => void;
22
24
  onRemove?: () => void;
23
25
  }
24
26
  /** Messenger's inline recorder; adapters supply media state and the optional text composer. */
25
- export declare function VoiceMessageComposer({ appearance, maxSeconds, busy, onRecord, actions, phase, elapsedMs, waveform, error, review, onStop, onSend, onRemove, renderTextComposer, renderAttachments }: VoiceComposerProps): React.JSX.Element;
27
+ export declare function VoiceMessageComposer({ appearance, maxSeconds, busy, onRecord, actions, phase, elapsedMs, waveform, error, review, onStop, onSend, onRemove, onRecordAgain, sendWhileRecording, renderTextComposer, renderAttachments }: VoiceComposerProps): React.JSX.Element;
26
28
  export declare function VoiceDraftPlayback({ appearance, playing, positionMs, durationMs, waveform, onToggle, onRemove, disabled, error, compact }: {
27
29
  appearance: MessagingAppearance;
28
30
  playing: boolean;