@robono/messaging-react-native 0.22.0 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BRIDGE-MESSENGER.md +72 -10
- package/CHANGELOG.md +6 -0
- package/SBOM.spdx.json +148 -100
- package/dist/chat-options.d.ts +5 -1
- package/dist/chat-options.js +2 -2
- package/dist/contact-directory.d.ts +2 -0
- package/dist/contact-directory.js +9 -1
- package/dist/expo-bridge.d.ts +6 -0
- package/dist/expo-bridge.js +13 -2
- package/dist/expo-notification-cleanup.js +3 -3
- package/dist/expo-notifications.js +7 -3
- package/dist/expo-screen.d.ts +3 -0
- package/dist/expo-screen.js +31 -22
- package/dist/index.js +1 -1
- package/dist/media-readiness.d.ts +2 -0
- package/dist/media-readiness.js +1 -0
- package/dist/playback-reporting.d.ts +8 -0
- package/dist/playback-reporting.js +32 -0
- package/package.json +9 -5
package/dist/chat-options.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
/** Supplied full Messengers connect these to the authenticated inbox automatically. */
|
|
3
3
|
export type ConversationActions = import('@robono/messaging').MessagingConversationActions;
|
|
4
|
-
export declare function ChatOptions({ actions, privacy, onClose, accent }: {
|
|
4
|
+
export declare function ChatOptions({ actions, privacy, online, onClose, accent }: {
|
|
5
|
+
online?: {
|
|
6
|
+
hidden: boolean;
|
|
7
|
+
set: (hidden: boolean) => Promise<void>;
|
|
8
|
+
};
|
|
5
9
|
actions?: ConversationActions;
|
|
6
10
|
privacy?: {
|
|
7
11
|
enabled: boolean;
|
package/dist/chat-options.js
CHANGED
|
@@ -4,7 +4,7 @@ import { Pressable, ScrollView, View } from 'react-native';
|
|
|
4
4
|
import { Text } from './typography.js';
|
|
5
5
|
import { MessagingPopup, useMessagingPopupColors } from './popup.js';
|
|
6
6
|
import { useRobonoLocale } from './localization.js';
|
|
7
|
-
export function ChatOptions({ actions, privacy, onClose, accent }) {
|
|
7
|
+
export function ChatOptions({ actions, privacy, online, onClose, accent }) {
|
|
8
8
|
const c = useMessagingPopupColors(undefined, 'options');
|
|
9
9
|
const { text: uiText } = useRobonoLocale();
|
|
10
10
|
const [busy, setBusy] = useState(false), [error, setError] = useState(''), [confirmDelete, setConfirmDelete] = useState(false);
|
|
@@ -21,5 +21,5 @@ export function ChatOptions({ actions, privacy, onClose, accent }) {
|
|
|
21
21
|
return _jsx(MessagingPopup, { screen: "options", background: c.background, title: uiText(confirmDelete ? 'Delete chat?' : 'Chat options'), compact: confirmDelete, closeDisabled: busy, onClose: () => { if (confirmDelete)
|
|
22
22
|
setConfirmDelete(false);
|
|
23
23
|
else
|
|
24
|
-
onClose(); }, children: _jsxs(ScrollView, { contentContainerStyle: { gap: 16, paddingBottom: 12 }, children: [confirmDelete ? _jsxs(_Fragment, { children: [_jsx(Text, { style: { color: c.secondary, fontSize: 16, lineHeight: 23 }, children: uiText('This removes the chat and its messages from your history. The other person keeps their copy. New messages can appear again.') }), _jsxs(View, { style: { flexDirection: 'row', gap: 12 }, children: [_jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText('Cancel'), disabled: busy, onPress: () => setConfirmDelete(false), style: { flex: 1, minHeight: 48, alignItems: 'center', justifyContent: 'center' }, children: _jsx(Text, { style: { color: c.foreground, fontSize: 16 }, children: uiText('Cancel') }) }), _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText('Delete chat'), disabled: busy, onPress: () => void save(async () => { await actions.deleteConversation(); onClose(); }), style: { flex: 1, minHeight: 48, borderRadius: 12, backgroundColor: '#b72d34', alignItems: 'center', justifyContent: 'center' }, children: _jsx(Text, { style: { color: '#fff', fontSize: 16, fontWeight: '600' }, children: uiText('Delete chat') }) })] })] }) : _jsxs(_Fragment, { children: [actions?.setMuted && row(uiText('Mute notifications'), actions.muted, () => actions.setMuted(!actions.muted)), privacy && row(uiText('Privacy Lens'), privacy.enabled, () => privacy.set(!privacy.enabled)), actions?.deleteConversation && _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText('Delete chat'), onPress: () => setConfirmDelete(true), style: { minHeight: 48, justifyContent: 'center' }, children: _jsx(Text, { style: { color: '#ff8282', fontSize: 17 }, children: uiText('Delete chat') }) })] }), !!error && _jsx(Text, { accessibilityRole: "alert", style: { color: c.foreground }, children: error })] }) });
|
|
24
|
+
onClose(); }, children: _jsxs(ScrollView, { contentContainerStyle: { gap: 16, paddingBottom: 12 }, children: [confirmDelete ? _jsxs(_Fragment, { children: [_jsx(Text, { style: { color: c.secondary, fontSize: 16, lineHeight: 23 }, children: uiText('This removes the chat and its messages from your history. The other person keeps their copy. New messages can appear again.') }), _jsxs(View, { style: { flexDirection: 'row', gap: 12 }, children: [_jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText('Cancel'), disabled: busy, onPress: () => setConfirmDelete(false), style: { flex: 1, minHeight: 48, alignItems: 'center', justifyContent: 'center' }, children: _jsx(Text, { style: { color: c.foreground, fontSize: 16 }, children: uiText('Cancel') }) }), _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText('Delete chat'), disabled: busy, onPress: () => void save(async () => { await actions.deleteConversation(); onClose(); }), style: { flex: 1, minHeight: 48, borderRadius: 12, backgroundColor: '#b72d34', alignItems: 'center', justifyContent: 'center' }, children: _jsx(Text, { style: { color: '#fff', fontSize: 16, fontWeight: '600' }, children: uiText('Delete chat') }) })] })] }) : _jsxs(_Fragment, { children: [actions?.setMuted && row(uiText('Mute notifications'), actions.muted, () => actions.setMuted(!actions.muted)), online && row(uiText('Hide my online status on all devices'), online.hidden, () => online.set(!online.hidden)), privacy && row(uiText('Privacy Lens'), privacy.enabled, () => privacy.set(!privacy.enabled)), actions?.deleteConversation && _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText('Delete chat'), onPress: () => setConfirmDelete(true), style: { minHeight: 48, justifyContent: 'center' }, children: _jsx(Text, { style: { color: '#ff8282', fontSize: 17 }, children: uiText('Delete chat') }) })] }), !!error && _jsx(Text, { accessibilityRole: "alert", style: { color: c.foreground }, children: error })] }) });
|
|
25
25
|
}
|
|
@@ -11,6 +11,8 @@ export interface MessagingDirectoryContact {
|
|
|
11
11
|
detail: string;
|
|
12
12
|
/** False keeps the entry visible with its explanation and no composer. */
|
|
13
13
|
available: boolean;
|
|
14
|
+
/** Fresh authorized status converted to this device’s clock; expires locally. */
|
|
15
|
+
onlineUntil?: number;
|
|
14
16
|
}
|
|
15
17
|
export interface MessagingDirectoryOptions {
|
|
16
18
|
directory?: readonly MessagingDirectoryContact[];
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { messagingAvatarStyle, messagingFriendsColors } from '@robono/messaging';
|
|
3
|
+
import { useRobonoLocale } from './localization.js';
|
|
4
|
+
import { useEffect, useMemo, useState } from 'react';
|
|
3
5
|
import { Image, Pressable, View } from 'react-native';
|
|
4
6
|
import { Text } from './typography.js';
|
|
5
7
|
export function directoryWithoutChats(directory, chats, query = '') {
|
|
@@ -12,6 +14,12 @@ export function directoryWithoutChats(directory, chats, query = '') {
|
|
|
12
14
|
});
|
|
13
15
|
}
|
|
14
16
|
export function MessagingDirectoryRow({ contact, appearance, onPress }) {
|
|
17
|
+
const { text: uiText } = useRobonoLocale();
|
|
18
|
+
const deadline = useMemo(() => Math.min(contact.onlineUntil ?? 0, Date.now() + 45000), [contact.onlineUntil]);
|
|
19
|
+
const [now, setNow] = useState(Date.now());
|
|
20
|
+
useEffect(() => { setNow(Date.now()); const remaining = Math.min(45000, Math.max(0, deadline - Date.now())); if (!remaining)
|
|
21
|
+
return; const timer = setTimeout(() => setNow(Date.now()), remaining + 1); return () => clearTimeout(timer); }, [deadline]);
|
|
22
|
+
const online = contact.available && Number.isFinite(contact.onlineUntil) && deadline > now;
|
|
15
23
|
const c = messagingFriendsColors(appearance), f = appearance.screens?.friends, avatar = messagingAvatarStyle(f?.avatarSize ?? 40, f?.avatarShape), padding = f?.rowSpacing === 'compact' ? 6 : f?.rowSpacing === 'relaxed' ? 16 : 10;
|
|
16
|
-
return _jsxs(Pressable, { testID: 'messaging-directory-' + contact.id, accessibilityRole: "button", accessibilityLabel: contact.name + ', ' + contact.status, onPress: onPress, style: { flexDirection: 'row', alignItems: 'center', gap: 12, paddingHorizontal: 12, paddingVertical: padding, minHeight: Math.max(44, avatar.height + padding * 2) }, children: [appearance.screens?.friends?.showAvatars !== false && (contact.avatarUrl ? _jsx(Image, { source: { uri: contact.avatarUrl }, style: { ...avatar } }) : _jsx(View, { style: { ...avatar, backgroundColor: c.accent + '20', alignItems: 'center', justifyContent: 'center' }, children: _jsx(Text, { style: { color: c.accent, fontSize: 18, fontWeight: '700' }, children: contact.name.slice(0, 1).toUpperCase() }) })), _jsxs(View, { style: { flex: 1, minWidth: 0 }, children: [_jsx(Text, { numberOfLines: 1, style: { color: c.foreground, fontSize: f?.nameSize ?? 16, fontWeight: '700' }, children: contact.name }), _jsx(Text, { numberOfLines: f?.previewLines ?? 1, style: { color: c.secondary, marginTop: 3, fontSize: f?.previewSize ?? 14 }, children: contact.status })] })] });
|
|
24
|
+
return _jsxs(Pressable, { testID: 'messaging-directory-' + contact.id, accessibilityRole: "button", accessibilityLabel: contact.name + ', ' + contact.status, onPress: onPress, style: { flexDirection: 'row', alignItems: 'center', gap: 12, paddingHorizontal: 12, paddingVertical: padding, minHeight: Math.max(44, avatar.height + padding * 2) }, children: [appearance.screens?.friends?.showAvatars !== false && (contact.avatarUrl ? _jsx(Image, { source: { uri: contact.avatarUrl }, style: { ...avatar } }) : _jsx(View, { style: { ...avatar, backgroundColor: c.accent + '20', alignItems: 'center', justifyContent: 'center' }, children: _jsx(Text, { style: { color: c.accent, fontSize: 18, fontWeight: '700' }, children: contact.name.slice(0, 1).toUpperCase() }) })), _jsxs(View, { style: { flex: 1, minWidth: 0 }, children: [_jsx(Text, { numberOfLines: 1, style: { color: c.foreground, fontSize: f?.nameSize ?? 16, fontWeight: '700' }, children: contact.name }), online && _jsx(View, { testID: "directory-online", accessibilityLabel: uiText("Online now"), style: { width: 8, height: 8, borderRadius: 4, backgroundColor: '#2e9d63' } }), _jsx(Text, { numberOfLines: f?.previewLines ?? 1, style: { color: c.secondary, marginTop: 3, fontSize: f?.previewSize ?? 14 }, children: contact.status })] })] });
|
|
17
25
|
}
|
package/dist/expo-bridge.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export declare function createExpoBridgeMessenger(options: {
|
|
|
5
5
|
userId: string;
|
|
6
6
|
connectionId: string;
|
|
7
7
|
getAccessToken: () => Promise<string>;
|
|
8
|
+
foregroundPresence?: boolean;
|
|
8
9
|
fetch?: typeof fetch;
|
|
9
10
|
namespace?: string;
|
|
10
11
|
persistence?: false;
|
|
@@ -14,6 +15,11 @@ export declare function createExpoBridgeMessenger(options: {
|
|
|
14
15
|
client: import("@robono/messaging").MessagingClient;
|
|
15
16
|
storage: import("./media-controller.js").MessagingMediaStorage;
|
|
16
17
|
audioSession: MessagingAudioSession;
|
|
18
|
+
presence: {
|
|
19
|
+
start(): void;
|
|
20
|
+
stop(): Promise<void>;
|
|
21
|
+
dispose(): Promise<void>;
|
|
22
|
+
} | undefined;
|
|
17
23
|
conversationId: string;
|
|
18
24
|
open: () => Promise<void>;
|
|
19
25
|
handlePush: (payload: unknown) => Promise<boolean>;
|
package/dist/expo-bridge.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { AppState } from 'react-native';
|
|
2
|
+
import * as Crypto from 'expo-crypto';
|
|
3
|
+
import { createBridgePresenceSession } from '@robono/messaging';
|
|
1
4
|
import { bridgeMessengerFetch, bridgeLanguageRequest, createMessagingTransport, refreshBridgeMessengerFromPush } from '@robono/messaging';
|
|
2
5
|
import { createExpoMessagingClient, expoOutbox } from './expo-outbox.js';
|
|
3
6
|
import { createExpoMessagingStorage, createExpoMessagingAudioSession } from './expo-media.js';
|
|
@@ -22,8 +25,16 @@ export function createExpoBridgeMessenger(options) {
|
|
|
22
25
|
return () => { abort.abort(); release(); };
|
|
23
26
|
});
|
|
24
27
|
const audioSession = options.audioSession ?? createExpoMessagingAudioSession({ isCallActive: options.isCallActive });
|
|
25
|
-
|
|
28
|
+
const presence = options.foregroundPresence ? createBridgePresenceSession({ request: createMessagingTransport({ ...options, fetch: transportFetch }), connectionId: options.connectionId, sessionId: Crypto.randomUUID() }) : undefined;
|
|
29
|
+
const change = (state) => { if (state === 'active')
|
|
30
|
+
presence?.start();
|
|
31
|
+
else
|
|
32
|
+
void presence?.stop(); };
|
|
33
|
+
const listener = presence ? AppState.addEventListener('change', change) : undefined;
|
|
34
|
+
change(AppState.currentState);
|
|
35
|
+
const stopPresence = () => { listener?.remove(); return presence?.dispose(); };
|
|
36
|
+
return { client, storage, audioSession, presence, conversationId: options.connectionId,
|
|
26
37
|
open: () => client.open(options.connectionId),
|
|
27
38
|
handlePush: (payload) => refreshBridgeMessengerFromPush(client, options.connectionId, payload),
|
|
28
|
-
signOut: () => client.signOut(), dispose: () => client.dispose(), };
|
|
39
|
+
signOut: async () => { await stopPresence(); await client.signOut(); }, dispose: () => { void stopPresence(); client.dispose(); }, };
|
|
29
40
|
}
|
|
@@ -48,7 +48,7 @@ export const rememberNotificationAccount = (scope, enabled) => serial(async () =
|
|
|
48
48
|
async function savedReads(scope) {
|
|
49
49
|
try {
|
|
50
50
|
const data = JSON.parse(await SecureStore.getItemAsync(readKey(scope)) ?? '[]');
|
|
51
|
-
return Array.isArray(data) ? data.map(r => Array.isArray(r) ? { event: 'robono.messaging.read', accountScope: scope, conversationId: r[0], messageId: r[1], kind: r[2], savedAt: r[3] } : r).filter(r => parseMessagingReadNotification(r) && r.savedAt > Date.now() - 7 * 86400000) : [];
|
|
51
|
+
return Array.isArray(data) ? data.map(r => Array.isArray(r) ? { event: 'robono.messaging.read', accountScope: scope, conversationId: r[0], messageId: r[1], kind: r[2], savedAt: r[3], ...(r[4] ? { source: r[4] } : {}) } : r).filter(r => parseMessagingReadNotification(r) && r.savedAt > Date.now() - 7 * 86400000) : [];
|
|
52
52
|
}
|
|
53
53
|
catch {
|
|
54
54
|
return [];
|
|
@@ -67,10 +67,10 @@ export async function dismissReadNotification(value) {
|
|
|
67
67
|
return serial(async () => {
|
|
68
68
|
if (!(await accounts()).includes(read.accountScope))
|
|
69
69
|
return false;
|
|
70
|
-
const reads = await savedReads(read.accountScope), previous = reads.find(r => r.conversationId === read.conversationId && r.kind === read.kind && (read.kind !== 'message' || r.messageId === read.messageId));
|
|
70
|
+
const reads = await savedReads(read.accountScope), previous = reads.find(r => r.source === read.source && r.conversationId === read.conversationId && r.kind === read.kind && (read.kind !== 'message' || r.messageId === read.messageId));
|
|
71
71
|
const newer = !previous || read.messageId.length > previous.messageId.length || read.messageId.length === previous.messageId.length && read.messageId >= previous.messageId;
|
|
72
72
|
if (newer)
|
|
73
|
-
await SecureStore.setItemAsync(readKey(read.accountScope), JSON.stringify([...reads.filter(r => r !== previous), { ...read, savedAt: Date.now() }].slice(-16).map(r => [r.conversationId, r.messageId, r.kind, r.savedAt])), { keychainAccessible: SecureStore.AFTER_FIRST_UNLOCK_THIS_DEVICE_ONLY });
|
|
73
|
+
await SecureStore.setItemAsync(readKey(read.accountScope), JSON.stringify([...reads.filter(r => r !== previous), { ...read, savedAt: Date.now() }].slice(-16).map(r => [r.conversationId, r.messageId, r.kind, r.savedAt, r.source])), { keychainAccessible: SecureStore.AFTER_FIRST_UNLOCK_THIS_DEVICE_ONLY });
|
|
74
74
|
for (const n of await Notifications.getPresentedNotificationsAsync())
|
|
75
75
|
if (readNotificationCovers(read, presentedNotificationData(n)))
|
|
76
76
|
await Notifications.dismissNotificationAsync(n.request.identifier);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as Notifications from 'expo-notifications';
|
|
2
|
+
import { getIosPushNotificationServiceEnvironmentAsync } from 'expo-application';
|
|
2
3
|
import * as Crypto from 'expo-crypto';
|
|
3
4
|
import * as SecureStore from 'expo-secure-store';
|
|
4
5
|
import { Platform, AppState } from 'react-native';
|
|
@@ -40,7 +41,10 @@ export async function connectExpoMessagingNotifications(options) {
|
|
|
40
41
|
if (disposed || closing)
|
|
41
42
|
return;
|
|
42
43
|
const system = await options.systemCalls?.registration();
|
|
43
|
-
const
|
|
44
|
+
const appleEnvironment = Platform.OS === 'ios' ? await getIosPushNotificationServiceEnvironmentAsync() : undefined;
|
|
45
|
+
if (Platform.OS === 'ios' && !['development', 'production'].includes(String(appleEnvironment)))
|
|
46
|
+
throw Error('This iPhone build has no Apple push environment. Rebuild with Push Notifications enabled.');
|
|
47
|
+
const data = await request({ operation: 'register-device', calling: !!options.onCall, ...system, ...(appleEnvironment ? { appleEnvironment } : {}), deviceId, provider: Platform.OS === 'ios' ? 'apns' : 'fcm', token: String(token.data) });
|
|
44
48
|
if (data.accountScope !== status.accountScope)
|
|
45
49
|
throw Error('The signed-in account changed. Reconnect notifications for the new account.');
|
|
46
50
|
});
|
|
@@ -79,11 +83,11 @@ export async function connectExpoMessagingNotifications(options) {
|
|
|
79
83
|
return;
|
|
80
84
|
const shown = (await Notifications.getPresentedNotificationsAsync()).map(n => ({ id: n.request.identifier, event: parseMessagingNotification(presentedNotificationData(n)) })).filter(n => n.event?.accountScope === accountScope);
|
|
81
85
|
for (let i = 0; i < shown.length; i += 100) {
|
|
82
|
-
const batch = shown.slice(i, i + 100), result = await request({ operation: 'notification-reconcile', messages: batch.map(n => ({ conversationId: n.event.conversationId, messageId: n.event.messageId })) });
|
|
86
|
+
const batch = shown.slice(i, i + 100), result = await request({ operation: 'notification-reconcile', messages: batch.map(n => ({ conversationId: n.event.conversationId, messageId: n.event.messageId, ...(n.event.source ? { source: n.event.source } : {}) })) });
|
|
83
87
|
if (disposed || closing || result.accountScope !== accountScope || !Array.isArray(result.stale))
|
|
84
88
|
return;
|
|
85
89
|
for (const n of batch)
|
|
86
|
-
if (result.stale.some((m) => m.conversationId === n.event.conversationId && m.messageId === n.event.messageId))
|
|
90
|
+
if (result.stale.some((m) => m.conversationId === n.event.conversationId && m.messageId === n.event.messageId && m.source === n.event.source))
|
|
87
91
|
await Notifications.dismissNotificationAsync(n.id);
|
|
88
92
|
}
|
|
89
93
|
})().finally(() => { reconciling = undefined; });
|
package/dist/expo-screen.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { MessagingPlaybackEvent } from '@robono/messaging';
|
|
1
2
|
import type { MessagingViewerPolicy } from '@robono/messaging';
|
|
2
3
|
export { createExpoMessagingClient } from './expo-outbox.js';
|
|
3
4
|
import React from 'react';
|
|
@@ -37,6 +38,8 @@ export interface ExpoMessagingScreenProps extends Omit<MessagingScreenProps, 'pi
|
|
|
37
38
|
mediaViewer?: MessagingViewerPolicy<LocalMessagingMedia>;
|
|
38
39
|
onDownloadAttachment?: MessagingAttachmentDownload;
|
|
39
40
|
/** Optional timing callback from native image/frame/playback readiness, measured from opening. */
|
|
41
|
+
/** Observed playback events. Persist eventId for deduplication; never infer completion from start. */
|
|
42
|
+
onPlaybackEvent?: (event: MessagingPlaybackEvent) => void;
|
|
40
43
|
onMediaReady?: (event: {
|
|
41
44
|
messageId: string;
|
|
42
45
|
kind: string;
|
package/dist/expo-screen.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { usePlaybackReporting } from './playback-reporting.js';
|
|
2
3
|
import { Linking } from 'react-native';
|
|
3
4
|
import { isRemoteMessagingAsset } from './media-access.js';
|
|
4
5
|
import { ExpoDocumentPreview } from './expo-document.js';
|
|
@@ -31,7 +32,7 @@ import { MessagingScreen, useMessagingUI } from './index.js';
|
|
|
31
32
|
import { VoiceMessageComposer, VoiceDraftPlayback } from './voice-composer.js';
|
|
32
33
|
import { VoicePlayback, MediaViewer } from './media-ui.js';
|
|
33
34
|
import { MessagingMediaController } from './media-controller.js';
|
|
34
|
-
import { MediaReadiness, StreamRecovery } from './media-readiness.js';
|
|
35
|
+
import { MediaReadiness, MediaPlayback, StreamRecovery } from './media-readiness.js';
|
|
35
36
|
import { RecentMessagingMedia } from './recent-media.js';
|
|
36
37
|
import { copyMessagingCache, createExpoMessagingDevice } from './expo-media.js';
|
|
37
38
|
export { createExpoMessagingAudioSession, createExpoMessagingDevice, createExpoMessagingStorage } from './expo-media.js';
|
|
@@ -78,6 +79,7 @@ function VoicePlayer({ file, audio, design, inline, draft, autoPlay = false }) {
|
|
|
78
79
|
const { text: uiText, locale: uiLocale, number: uiNumber, count: uiCount } = useRobonoLocale();
|
|
79
80
|
const [playing, setPlaying] = useState(false), [position, setPosition] = useState(0), [error, setError] = useState('');
|
|
80
81
|
const source = useMemo(() => file.stream ? { uri: file.uri, headers: file.stream.headers } : file.uri, [file]);
|
|
82
|
+
const reportPlayback = useContext(MediaPlayback);
|
|
81
83
|
const player = useAudioPlayer(source, { updateInterval: 100, downloadFirst: false, preferredForwardBufferDuration: 5, keepAudioSessionActive: true });
|
|
82
84
|
const mediaReady = useContext(MediaReadiness), recover = useContext(StreamRecovery);
|
|
83
85
|
const recovered = useRef(false), lastPosition = useRef(file.resumeAtMs ?? 0), playIntent = useRef(file.autoPlay ?? autoPlay);
|
|
@@ -143,6 +145,8 @@ function VoicePlayer({ file, audio, design, inline, draft, autoPlay = false }) {
|
|
|
143
145
|
restorePaused();
|
|
144
146
|
const subscription = player.addListener('playbackStatusUpdate', status => { if (!scope.alive)
|
|
145
147
|
return; setLoaded(status.isLoaded); if (status.didJustFinish) {
|
|
148
|
+
if (!draft)
|
|
149
|
+
reportPlayback(file.uri, { positionMs: player.duration * 1000, durationMs: player.duration * 1000, playing: false, ended: true, activeView: AppState.currentState === 'active' });
|
|
146
150
|
playIntent.current = false;
|
|
147
151
|
lastPosition.current = 0;
|
|
148
152
|
setPosition(0);
|
|
@@ -182,6 +186,8 @@ function VoicePlayer({ file, audio, design, inline, draft, autoPlay = false }) {
|
|
|
182
186
|
const timer = setInterval(() => {
|
|
183
187
|
if (!scope.alive)
|
|
184
188
|
return;
|
|
189
|
+
if (!draft)
|
|
190
|
+
reportPlayback(file.uri, { positionMs: player.currentTime * 1000, durationMs: player.duration * 1000, playing: player.playing, activeView: AppState.currentState === 'active', rate: player.playbackRate });
|
|
185
191
|
if (audio.isAvailable?.() === false)
|
|
186
192
|
void stop();
|
|
187
193
|
if (player.currentTime > 0)
|
|
@@ -200,7 +206,8 @@ function VoicePlayer({ file, audio, design, inline, draft, autoPlay = false }) {
|
|
|
200
206
|
}, 150);
|
|
201
207
|
const app = AppState.addEventListener('change', state => { if (state !== 'active')
|
|
202
208
|
void stop(); });
|
|
203
|
-
return () => {
|
|
209
|
+
return () => { if (!draft)
|
|
210
|
+
reportPlayback(file.uri, null); scope.alive = false; cancelled = true; subscription.remove(); clearTimeout(startupTimeout); clearInterval(timer); app.remove(); void stop().finally(() => voiceStops.delete(stop)); };
|
|
204
211
|
}, [player]);
|
|
205
212
|
async function toggle() {
|
|
206
213
|
const scope = current.current;
|
|
@@ -250,7 +257,7 @@ function VoicePlayer({ file, audio, design, inline, draft, autoPlay = false }) {
|
|
|
250
257
|
}
|
|
251
258
|
function VideoPlayer({ file, audio, posterUri }) {
|
|
252
259
|
const { text: uiText, locale: uiLocale, number: uiNumber, count: uiCount } = useRobonoLocale();
|
|
253
|
-
const mediaReady = useContext(MediaReadiness), recover = useContext(StreamRecovery);
|
|
260
|
+
const mediaReady = useContext(MediaReadiness), recover = useContext(StreamRecovery), reportPlayback = useContext(MediaPlayback);
|
|
254
261
|
const source = useMemo(() => file.stream ? { uri: file.uri, headers: file.stream.headers, contentType: 'progressive', useCaching: false } : file.uri, [file]);
|
|
255
262
|
const player = useVideoPlayer(source, p => { p.loop = false; p.audioMixingMode = 'mixWithOthers'; if (file.stream)
|
|
256
263
|
p.bufferOptions = { preferredForwardBufferDuration: 5, minBufferForPlayback: 0.5 }; });
|
|
@@ -280,7 +287,7 @@ function VideoPlayer({ file, audio, posterUri }) {
|
|
|
280
287
|
setError(e.message); });
|
|
281
288
|
let consumed = false;
|
|
282
289
|
const timer = setInterval(() => { if (!alive)
|
|
283
|
-
return; if (!consumed && player.playing && player.currentTime > 0) {
|
|
290
|
+
return; reportPlayback(file.uri, { positionMs: player.currentTime * 1000, durationMs: player.duration * 1000, playing: player.playing, activeView: AppState.currentState === 'active', rate: player.playbackRate }); if (!consumed && player.playing && player.currentTime > 0) {
|
|
284
291
|
consumed = true;
|
|
285
292
|
mediaReady('video-playing', file.uri);
|
|
286
293
|
} if (player.currentTime > 0)
|
|
@@ -293,6 +300,7 @@ function VideoPlayer({ file, audio, posterUri }) {
|
|
|
293
300
|
release = undefined;
|
|
294
301
|
} }, 100);
|
|
295
302
|
// Native controls must retain resume intent and respect the host's call audio session.
|
|
303
|
+
const ended = player.addListener('playToEnd', () => reportPlayback(file.uri, { positionMs: player.duration * 1000, durationMs: player.duration * 1000, playing: false, ended: true, activeView: AppState.currentState === 'active' }));
|
|
296
304
|
const playback = player.addListener('playingChange', ({ isPlaying }) => {
|
|
297
305
|
if (recovered || !alive)
|
|
298
306
|
return;
|
|
@@ -316,7 +324,7 @@ function VideoPlayer({ file, audio, posterUri }) {
|
|
|
316
324
|
desired.current = false;
|
|
317
325
|
player.pause();
|
|
318
326
|
} });
|
|
319
|
-
return () => { alive = false; clearTimeout(timeout); clearInterval(timer); listener.remove(); playback.remove(); app.remove(); try {
|
|
327
|
+
return () => { reportPlayback(file.uri, null); ended.remove(); alive = false; clearTimeout(timeout); clearInterval(timer); listener.remove(); playback.remove(); app.remove(); try {
|
|
320
328
|
player.pause();
|
|
321
329
|
}
|
|
322
330
|
catch { } void release?.().catch(() => { }); };
|
|
@@ -606,6 +614,7 @@ function ExpoMessagingScreenContent({ storage, audioSession, renderConversation,
|
|
|
606
614
|
return;
|
|
607
615
|
} opened.current = null; message.current = null; await controller.previewLocal(file, record.message.kind, record.message); },
|
|
608
616
|
};
|
|
617
|
+
const reportPlayback = usePlaybackReporting({ actorId: props.userId, createId: () => Crypto.randomUUID(), emit: props.onPlaybackEvent, resolve: uri => { const m = message.current; return m && m.conversationId === current.current.client.getSnapshot().conversationId && controller.getSnapshot().file?.uri === uri ? m : null; } });
|
|
609
618
|
const mediaReady = (stage, uri) => { const event = opened.current; if (!event || controller.getSnapshot().phase !== 'viewing' || controller.getSnapshot().file?.uri !== uri)
|
|
610
619
|
return; if (stage !== 'video-frame' && message.current?.conversationId === current.current.client.getSnapshot().conversationId)
|
|
611
620
|
void current.current.client.consumeMessage(event.messageId).catch(() => { }); if (event.reported.has(stage))
|
|
@@ -613,21 +622,21 @@ function ExpoMessagingScreenContent({ storage, audioSession, renderConversation,
|
|
|
613
622
|
current.current.onMediaReady?.({ messageId: event.messageId, kind: event.kind, stage, elapsedMs: Date.now() - event.started });
|
|
614
623
|
}
|
|
615
624
|
catch { } };
|
|
616
|
-
return _jsx(MessagingTypography, { appearance: props.appearance ?? state.settings?.appearance ?? defaultMessagingSettings().appearance, children: _jsx(StreamRecovery.Provider, { value: (uri, position, playing) => { void controller.fallbackStream(uri, position, playing); }, children:
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
625
|
+
return _jsx(MessagingTypography, { appearance: props.appearance ?? state.settings?.appearance ?? defaultMessagingSettings().appearance, children: _jsx(StreamRecovery.Provider, { value: (uri, position, playing) => { void controller.fallbackStream(uri, position, playing); }, children: _jsx(MediaReadiness.Provider, { value: mediaReady, children: _jsxs(MediaPlayback.Provider, { value: reportPlayback, children: [renderConversation ? renderConversation(screenProps) : _jsx(MessagingScreen, { ...screenProps }), _jsx(MessagingMediaOverlay, { onDocumentLink: props.linkHandling?.webLinks === false || (props.appearance ?? state.settings?.appearance)?.linkHandling?.webLinks === false ? undefined : url => { const m = message.current, p = current.current; if (!m || controller.getSnapshot().phase !== 'viewing' || p.linkHandling?.webLinks === false)
|
|
626
|
+
return; void Promise.resolve().then(() => p.linkHandling?.openUrl ? p.linkHandling.openUrl(url, m) : Linking.openURL(url)).catch(() => { }); }, mediaViewer: props.mediaViewer, onDownloadAttachment: props.onDownloadAttachment, onDismiss: viewerDismissed, viewerActions: () => {
|
|
627
|
+
const m = message.current;
|
|
628
|
+
if (!m || ![...state.messages, ...(state.latestVoices ?? [])].some(row => row.id === m.id && !row.deleted))
|
|
629
|
+
return {};
|
|
630
|
+
const action = (kind) => {
|
|
631
|
+
afterViewer.current = { kind, messageId: m.id, sequence: Date.now() };
|
|
632
|
+
void controller.cancel().then(() => {
|
|
633
|
+
// Some installed native runtimes omit onDismiss after a media modal closes.
|
|
634
|
+
// Keep the normal event fast path; retain a recovery delay for older native runtimes.
|
|
635
|
+
// Navigation/unmount clears the queued action, so it cannot open in another chat.
|
|
636
|
+
if (afterViewer.current)
|
|
637
|
+
dismissFallback.current = setTimeout(viewerDismissed, Platform.OS === 'ios' ? 500 : 250);
|
|
638
|
+
});
|
|
639
|
+
};
|
|
640
|
+
return { onForward: props.client.canForward(m) ? () => action('forward') : undefined, onDelete: m.senderId === props.userId && !m.readAt && state.messageActionsAvailable ? () => action('delete') : undefined };
|
|
641
|
+
}, inlineVoice: () => !!message.current, inlineRecorder: () => !!message.current && !!current.current.client.getSnapshot().settings?.features.voice, controller: controller, audio: audioSession, appearance: props.appearance ?? state.settings?.appearance ?? defaultMessagingSettings().appearance })] }) }) }) });
|
|
633
642
|
}
|
package/dist/index.js
CHANGED
|
@@ -319,7 +319,7 @@ export function MessagingHeader({ children } = {}) {
|
|
|
319
319
|
backgroundColor: c.incoming,
|
|
320
320
|
alignItems: "center",
|
|
321
321
|
justifyContent: "center",
|
|
322
|
-
}, 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, textAlign: chatDesign?.titleAlign ?? 'left', fontWeight: "800" }, children: state.conversation?.kind === 'group' ? state.conversation.name : contact.name }), chatDesign?.showActivity !== false && _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' ? _jsx(PrivacyControl, { color: header.foreground }) : (onContactOptions || 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: 42, height: 42, 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: 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, 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, { 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: 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)] }));
|
|
322
|
+
}, 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, textAlign: chatDesign?.titleAlign ?? 'left', fontWeight: "800" }, children: state.conversation?.kind === 'group' ? state.conversation.name : contact.name }), chatDesign?.showActivity !== false && _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' ? _jsx(PrivacyControl, { color: header.foreground }) : (onContactOptions || 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: 42, height: 42, 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, 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)] }));
|
|
323
323
|
}
|
|
324
324
|
function PrivacyControl({ color }) {
|
|
325
325
|
const messagingPopupColors = useMessagingPopupColors();
|
|
@@ -2,3 +2,5 @@ export type MediaReadyStage = 'image-loaded' | 'video-frame' | 'audio-playing' |
|
|
|
2
2
|
export declare const MediaReadiness: import("react").Context<(stage: MediaReadyStage, uri: string) => void>;
|
|
3
3
|
/** Internal recovery channel; URLs are matched in memory, never logged. */
|
|
4
4
|
export declare const StreamRecovery: import("react").Context<(uri: string, positionMs: number, autoPlay: boolean) => void>;
|
|
5
|
+
import type { PlaybackSample } from '@robono/messaging';
|
|
6
|
+
export declare const MediaPlayback: import("react").Context<(uri: string, sample: PlaybackSample | null) => void>;
|
package/dist/media-readiness.js
CHANGED
|
@@ -2,3 +2,4 @@ import { createContext } from 'react';
|
|
|
2
2
|
export const MediaReadiness = createContext(() => { });
|
|
3
3
|
/** Internal recovery channel; URLs are matched in memory, never logged. */
|
|
4
4
|
export const StreamRecovery = createContext(() => { });
|
|
5
|
+
export const MediaPlayback = createContext(() => { });
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type MessagingMessage, type MessagingPlaybackEvent, type PlaybackSample } from '@robono/messaging';
|
|
2
|
+
/** Connect the shared players to the owning screen, never draft/translation players. */
|
|
3
|
+
export declare function usePlaybackReporting(options: {
|
|
4
|
+
actorId: string;
|
|
5
|
+
resolve: (uri: string) => MessagingMessage | null;
|
|
6
|
+
emit?: (event: MessagingPlaybackEvent) => void;
|
|
7
|
+
createId: () => string;
|
|
8
|
+
}): (uri: string, sample: PlaybackSample | null) => void;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { useEffect, useMemo, useRef } from 'react';
|
|
2
|
+
import { createMessagingPlaybackTracker } from '@robono/messaging';
|
|
3
|
+
/** Connect the shared players to the owning screen, never draft/translation players. */
|
|
4
|
+
export function usePlaybackReporting(options) {
|
|
5
|
+
const current = useRef(options);
|
|
6
|
+
current.current = options;
|
|
7
|
+
const reporting = useMemo(() => {
|
|
8
|
+
const trackers = new Map();
|
|
9
|
+
return { sample(uri, sample) {
|
|
10
|
+
if (!sample) {
|
|
11
|
+
trackers.get(uri)?.close();
|
|
12
|
+
trackers.delete(uri);
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
if (!current.current.emit)
|
|
16
|
+
return;
|
|
17
|
+
let tracker = trackers.get(uri);
|
|
18
|
+
if (!tracker) {
|
|
19
|
+
const message = current.current.resolve(uri);
|
|
20
|
+
if (!message || !['voice', 'video'].includes(message.kind))
|
|
21
|
+
return;
|
|
22
|
+
const actorId = current.current.actorId;
|
|
23
|
+
tracker = createMessagingPlaybackTracker({ sessionId: current.current.createId(), messageId: message.id, conversationId: message.conversationId, actorId, kind: message.kind, emit: event => { if (current.current.actorId === actorId)
|
|
24
|
+
current.current.emit?.(event); } });
|
|
25
|
+
trackers.set(uri, tracker);
|
|
26
|
+
}
|
|
27
|
+
tracker.sample(sample);
|
|
28
|
+
}, close() { trackers.forEach(t => t.close()); trackers.clear(); } };
|
|
29
|
+
}, [options.actorId]);
|
|
30
|
+
useEffect(() => () => reporting.close(), [reporting]);
|
|
31
|
+
return reporting.sample;
|
|
32
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@robono/messaging-react-native",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.23.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": [
|
|
6
6
|
"./dist/expo-notification-cleanup.js"
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"prepack": "npm run build && node ../../scripts/generate-sdk-file-sbom.mjs"
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|
|
62
|
-
"@robono/messaging": "^0.
|
|
62
|
+
"@robono/messaging": "^0.17.0",
|
|
63
63
|
"react": ">=18.2 <20",
|
|
64
64
|
"react-native": ">=0.76 <1",
|
|
65
65
|
"expo-audio": ">=55 <57",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"expo-crypto": ">=55 <57",
|
|
72
72
|
"react-native-safe-area-context": ">=5 <6",
|
|
73
73
|
"react-native-svg": ">=15 <16",
|
|
74
|
-
"@robono/calling-react-native": "^0.
|
|
74
|
+
"@robono/calling-react-native": "^0.11.0",
|
|
75
75
|
"expo-clipboard": ">=8 <57",
|
|
76
76
|
"expo-image-manipulator": ">=14 <57",
|
|
77
77
|
"expo-video-thumbnails": ">=14 <57",
|
|
@@ -84,9 +84,10 @@
|
|
|
84
84
|
"expo-constants": ">=55 <57",
|
|
85
85
|
"@robono/location": "^0.4.1",
|
|
86
86
|
"expo-haptics": ">=55 <57",
|
|
87
|
-
"@robono/calling": "^0.
|
|
87
|
+
"@robono/calling": "^0.7.0",
|
|
88
88
|
"expo-media-library": ">=55 <57",
|
|
89
|
-
"expo-task-manager": ">=55.0.0 <57.0.0"
|
|
89
|
+
"expo-task-manager": ">=55.0.0 <57.0.0",
|
|
90
|
+
"expo-application": ">=55 <57"
|
|
90
91
|
},
|
|
91
92
|
"license": "SEE LICENSE IN LICENSE",
|
|
92
93
|
"peerDependenciesMeta": {
|
|
@@ -143,6 +144,9 @@
|
|
|
143
144
|
},
|
|
144
145
|
"expo-task-manager": {
|
|
145
146
|
"optional": true
|
|
147
|
+
},
|
|
148
|
+
"expo-application": {
|
|
149
|
+
"optional": true
|
|
146
150
|
}
|
|
147
151
|
},
|
|
148
152
|
"author": {
|