@robono/messaging-react-native 0.23.0 → 0.24.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 (59) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +83 -4
  3. package/RobonoMessagingRuntime.podspec +14 -0
  4. package/SBOM.spdx.json +893 -269
  5. package/android/build.gradle +7 -0
  6. package/android/src/main/AndroidManifest.xml +1 -0
  7. package/android/src/main/java/com/robono/messaging/RobonoBackupCrypto.java +27 -0
  8. package/android/src/main/java/com/robono/messaging/RobonoMessagingPackage.java +11 -0
  9. package/app.plugin.cjs +8 -2
  10. package/dist/account.d.ts +4 -1
  11. package/dist/account.js +33 -11
  12. package/dist/attachment-preview.d.ts +11 -10
  13. package/dist/attachment-preview.js +15 -12
  14. package/dist/backup.d.ts +24 -0
  15. package/dist/backup.js +157 -0
  16. package/dist/brand.js +4 -4
  17. package/dist/bubble-design.js +5 -3
  18. package/dist/contact-directory.d.ts +3 -1
  19. package/dist/contact-directory.js +3 -3
  20. package/dist/conversation-details.js +1 -1
  21. package/dist/delivery-bar.d.ts +2 -1
  22. package/dist/delivery-bar.js +2 -2
  23. package/dist/directory-navigation.d.ts +25 -0
  24. package/dist/directory-navigation.js +69 -0
  25. package/dist/expo-backup-crypto.d.ts +3 -0
  26. package/dist/expo-backup-crypto.js +17 -0
  27. package/dist/expo-backup-passkeys.d.ts +7 -0
  28. package/dist/expo-backup-passkeys.js +22 -0
  29. package/dist/expo-backup-settings.d.ts +4 -0
  30. package/dist/expo-backup-settings.js +41 -0
  31. package/dist/expo-inbox-preferences.d.ts +3 -0
  32. package/dist/expo-inbox-preferences.js +9 -0
  33. package/dist/expo-media.js +3 -3
  34. package/dist/expo-messenger.js +10 -5
  35. package/dist/expo-reviews.d.ts +3 -0
  36. package/dist/expo-reviews.js +40 -0
  37. package/dist/expo-screen.js +58 -25
  38. package/dist/expo-thumbnails.d.ts +4 -0
  39. package/dist/expo-thumbnails.js +25 -3
  40. package/dist/expo.d.ts +4 -0
  41. package/dist/expo.js +4 -0
  42. package/dist/forward.js +2 -2
  43. package/dist/header-colors.d.ts +5 -0
  44. package/dist/header-colors.js +7 -0
  45. package/dist/inbox.d.ts +5 -2
  46. package/dist/inbox.js +25 -53
  47. package/dist/index.d.ts +8 -5
  48. package/dist/index.js +78 -36
  49. package/dist/loading-messages.d.ts +5 -0
  50. package/dist/loading-messages.js +10 -0
  51. package/dist/media-access.d.ts +8 -0
  52. package/dist/media-access.js +6 -1
  53. package/dist/popup.d.ts +6 -3
  54. package/dist/popup.js +6 -6
  55. package/dist/reviews.d.ts +15 -0
  56. package/dist/reviews.js +204 -0
  57. package/dist/scheduled.js +5 -5
  58. package/ios/RobonoBackupCrypto.m +30 -0
  59. package/package.json +15 -6
@@ -0,0 +1,69 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useEffect, useLayoutEffect, useRef, useState } from 'react';
3
+ import { AppState, BackHandler, Image, Pressable, View } from 'react-native';
4
+ import { MessagingLoadingMessages } from './loading-messages.js';
5
+ import { messagingAvatarStyle, messagingScreenAppearance } from '@robono/messaging';
6
+ import { messagingHeaderColors } from './header-colors.js';
7
+ import { MessageIcon } from './icons.js';
8
+ import { MessagingTypography, Text } from './typography.js';
9
+ import { useRobonoLocale } from './localization.js';
10
+ const emptyDirectory = [];
11
+ /** Navigation is immediate; permission resolution must finish before any chat data or composer is mounted. */
12
+ export function useDirectoryNavigation(options) {
13
+ const latest = useRef(options);
14
+ latest.current = options;
15
+ const request = useRef(null);
16
+ const [selection, setSelection] = useState(null), [error, setError] = useState(''), [busy, setBusy] = useState(false);
17
+ const cancel = () => { request.current?.control.abort(); request.current = null; setSelection(null); setError(''); setBusy(false); };
18
+ useLayoutEffect(() => { cancel(); return () => { request.current?.control.abort(); request.current = null; }; }, [options.scope, options.userId]);
19
+ useEffect(() => { if (options.active === false)
20
+ cancel(); }, [options.active]);
21
+ useEffect(() => { const sub = AppState.addEventListener('change', state => { if (state !== 'active')
22
+ cancel(); }); return () => sub.remove(); }, []);
23
+ useLayoutEffect(() => {
24
+ if (!selection)
25
+ return;
26
+ const current = (options.directory ?? emptyDirectory).find(entry => entry.id === selection.id);
27
+ if (!current || current.available !== selection.available || current.contactId !== selection.contactId || current.conversationId !== selection.conversationId)
28
+ cancel();
29
+ }, [options.directory, selection]);
30
+ async function open(entry) {
31
+ request.current?.control.abort();
32
+ request.current = null;
33
+ setSelection(entry);
34
+ setError('');
35
+ setBusy(false);
36
+ if (!entry.available || !latest.current.onOpenDirectoryContact)
37
+ return;
38
+ const pending = { control: new AbortController(), entry };
39
+ request.current = pending;
40
+ setBusy(true);
41
+ try {
42
+ const row = await latest.current.onOpenDirectoryContact(entry, pending.control.signal);
43
+ const current = latest.current.directory?.find(value => value.id === entry.id);
44
+ if (request.current !== pending || pending.control.signal.aborted || !current?.available || current.contactId !== entry.contactId || current.conversationId !== entry.conversationId)
45
+ return;
46
+ request.current = null;
47
+ setSelection(null);
48
+ setBusy(false);
49
+ latest.current.onOpen(row);
50
+ }
51
+ catch (e) {
52
+ if (request.current === pending && !pending.control.signal.aborted)
53
+ setError(e instanceof Error ? e.message : 'This conversation could not be opened. Try again.');
54
+ }
55
+ finally {
56
+ if (request.current === pending) {
57
+ request.current = null;
58
+ setBusy(false);
59
+ }
60
+ }
61
+ }
62
+ return { selection, error, busy, open, cancel };
63
+ }
64
+ /** A normal chat destination, never a blocking dialog or a pretend authorized chat. */
65
+ export function MessagingDirectoryConversation({ entry, error, busy, appearance, onBack, onRetry }) {
66
+ const { text } = useRobonoLocale(), design = messagingScreenAppearance(appearance), header = messagingHeaderColors(design, false), chat = design.screens?.chat, avatar = messagingAvatarStyle(chat?.avatarSize ?? 38, chat?.avatarShape);
67
+ useEffect(() => { const sub = BackHandler.addEventListener('hardwareBackPress', () => { onBack(); return true; }); return () => sub.remove(); }, [onBack]);
68
+ return _jsx(MessagingTypography, { appearance: design, children: _jsxs(View, { testID: "messaging-directory-conversation", style: { flex: 1, minHeight: 0, backgroundColor: design.colors.background }, children: [_jsxs(View, { testID: "messaging-chat-header", style: { flexDirection: 'row', alignItems: 'center', paddingHorizontal: 12, paddingVertical: 4, minHeight: chat?.headerSize === 'roomy' ? 72 : chat?.headerSize === 'compact' ? 44 : undefined, backgroundColor: header.background, gap: 4 }, children: [_jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: text('Back'), onPress: onBack, style: { width: 44, minHeight: 44, alignSelf: 'stretch', marginStart: -12, marginEnd: -4, marginVertical: -4, alignItems: 'center', justifyContent: 'center' }, children: _jsx(MessageIcon, { name: "back", color: header.foreground, size: 32 }) }), _jsxs(View, { testID: "messaging-chat-identity", style: { flex: 1, minWidth: 0, flexDirection: 'row', alignItems: 'center', gap: 8 }, children: [design.showAvatars && (entry.avatarUrl ? _jsx(Image, { source: { uri: entry.avatarUrl }, style: { ...avatar, borderWidth: 1, borderColor: '#ffffff' } }) : _jsx(View, { style: { ...avatar, borderWidth: 1, borderColor: '#ffffff', backgroundColor: design.colors.incoming, alignItems: 'center', justifyContent: 'center' }, children: _jsx(Text, { style: { color: design.colors.incomingText }, children: entry.name.slice(0, 1) }) })), _jsx(Text, { numberOfLines: 1, style: { flex: 1, color: header.foreground, fontSize: chat?.titleSize ?? 18, textAlign: chat?.titleAlign ?? 'left', fontWeight: '800' }, children: entry.name })] })] }), _jsx(View, { style: { flex: 1, padding: 24, alignItems: 'center', justifyContent: 'center', gap: 16 }, children: busy ? _jsx(MessagingLoadingMessages, { color: design.colors.secondary }, entry.id) : _jsxs(_Fragment, { children: [_jsx(Text, { accessibilityRole: error ? 'alert' : undefined, style: { color: design.colors.secondary, textAlign: 'center', fontSize: 16, lineHeight: 24 }, children: error || entry.detail }), !!error && entry.available && _jsx(Pressable, { accessibilityRole: "button", onPress: onRetry, style: { minHeight: 44, justifyContent: 'center', paddingHorizontal: 16 }, children: _jsx(Text, { style: { color: design.colors.accent }, children: text('Try again') }) })] }) })] }) });
69
+ }
@@ -0,0 +1,3 @@
1
+ import type { MessagingBackupCrypto } from '@robono/messaging';
2
+ /** Interoperable with the web backup archive: AES-256-GCM, 96-bit IV, 128-bit tag. */
3
+ export declare function createExpoMessagingBackupCrypto(): MessagingBackupCrypto;
@@ -0,0 +1,17 @@
1
+ import { NativeModules } from 'react-native';
2
+ import { backupHex, backupUnhex } from '@robono/messaging';
3
+ import { AESEncryptionKey, AESSealedData, aesEncryptAsync, aesDecryptAsync, getRandomBytes } from 'expo-crypto';
4
+ /** Interoperable with the web backup archive: AES-256-GCM, 96-bit IV, 128-bit tag. */
5
+ export function createExpoMessagingBackupCrypto() {
6
+ return {
7
+ random: length => getRandomBytes(length),
8
+ ...(NativeModules.RobonoBackupCrypto ? { passwordKey: async (password, salt, iterations) => backupUnhex(await NativeModules.RobonoBackupCrypto.passwordKey(password, backupHex(salt), iterations)) } : {}),
9
+ async seal(key, plaintext, context) {
10
+ const sealed = await aesEncryptAsync(plaintext, await AESEncryptionKey.import(key), { nonce: { length: 12 }, tagLength: 16, additionalData: context });
11
+ return sealed.combined();
12
+ },
13
+ async open(key, bytes, context) {
14
+ return aesDecryptAsync(AESSealedData.fromCombined(bytes, { ivLength: 12, tagLength: 16 }), await AESEncryptionKey.import(key), { additionalData: context });
15
+ },
16
+ };
17
+ }
@@ -0,0 +1,7 @@
1
+ import { type MessagingBackupPasskeys } from '@robono/messaging';
2
+ /** Requires react-native-passkey, iOS associated domains and Android Digital Asset
3
+ * Links for the same RP ID. Unsupported providers never fall back to weaker keys. */
4
+ export declare function createExpoMessagingBackupPasskeys(options: {
5
+ rpId: string;
6
+ name: string;
7
+ }): MessagingBackupPasskeys;
@@ -0,0 +1,22 @@
1
+ import { NativeModules, Platform } from 'react-native';
2
+ import { getRandomBytes } from 'expo-crypto';
3
+ import { createMessagingBackupPasskeys } from '@robono/messaging';
4
+ /** Requires react-native-passkey, iOS associated domains and Android Digital Asset
5
+ * Links for the same RP ID. Unsupported providers never fall back to weaker keys. */
6
+ export function createExpoMessagingBackupPasskeys(options) {
7
+ const load = async () => { try {
8
+ return (await import('react-native-passkey')).Passkey;
9
+ }
10
+ catch {
11
+ return null;
12
+ } };
13
+ return createMessagingBackupPasskeys({ ...options, random: getRandomBytes, transport: {
14
+ async available() { if (!NativeModules.Passkey)
15
+ return false; if (Platform.OS === 'ios' && Number.parseInt(String(Platform.Version), 10) < 18)
16
+ return false; const passkey = await load(); return !!passkey?.isSupported(); },
17
+ async create(request) { const passkey = await load(); if (!passkey)
18
+ throw Error('Passkeys unavailable'); return passkey.create(request); },
19
+ async get(request) { const passkey = await load(); if (!passkey)
20
+ throw Error('Passkeys unavailable'); return passkey.get(request); },
21
+ } });
22
+ }
@@ -0,0 +1,4 @@
1
+ import type { MessagingBackupLocalSettings } from '@robono/messaging';
2
+ /** Recovery keys stay in Keychain/Keystore. Preferences contain no credentials.
3
+ * The scope must be identical to the durable history's endpoint/tenant/account scope. */
4
+ export declare function createExpoMessagingBackupSettings(endpoint: string, userId: string, namespace?: string): MessagingBackupLocalSettings;
@@ -0,0 +1,41 @@
1
+ import * as FS from 'expo-file-system/legacy';
2
+ import * as SecureStore from 'expo-secure-store';
3
+ import { randomUUID } from 'expo-crypto';
4
+ import { storageDigest } from './expo-storage-digest.js';
5
+ /** Recovery keys stay in Keychain/Keystore. Preferences contain no credentials.
6
+ * The scope must be identical to the durable history's endpoint/tenant/account scope. */
7
+ export function createExpoMessagingBackupSettings(endpoint, userId, namespace = 'default') {
8
+ const scope = storageDigest(JSON.stringify([endpoint, namespace, userId]));
9
+ const directory = async () => {
10
+ if (!FS.documentDirectory)
11
+ throw Error('Private backup settings are unavailable.');
12
+ return FS.documentDirectory + 'robono-backup-settings/' + await scope + '/';
13
+ };
14
+ const keyOptions = { keychainService: 'robono-messaging-backup', keychainAccessible: SecureStore.AFTER_FIRST_UNLOCK_THIS_DEVICE_ONLY };
15
+ const readEncryption = async () => { const raw = await SecureStore.getItemAsync('encryption-' + await scope, keyOptions); return raw ? JSON.parse(raw) : null; };
16
+ let pending = Promise.resolve();
17
+ return {
18
+ async readPreferences() { await pending.catch(() => { }); const file = await directory() + 'preferences.json'; const info = await FS.getInfoAsync(file); if (!info.exists)
19
+ return null; if (info.isDirectory || info.size > 4096)
20
+ throw Error('Backup settings could not be read.'); return JSON.parse(await FS.readAsStringAsync(file)); },
21
+ writePreferences(value) {
22
+ const work = pending.catch(() => { }).then(async () => {
23
+ const dir = await directory(), temp = dir + randomUUID() + '.tmp';
24
+ await FS.makeDirectoryAsync(dir, { intermediates: true });
25
+ try {
26
+ await FS.writeAsStringAsync(temp, JSON.stringify(value));
27
+ await FS.moveAsync({ from: temp, to: dir + 'preferences.json' });
28
+ }
29
+ finally {
30
+ await FS.deleteAsync(temp, { idempotent: true }).catch(() => { });
31
+ }
32
+ });
33
+ pending = work;
34
+ return work;
35
+ },
36
+ readEncryption,
37
+ async writeEncryption(value) { await SecureStore.setItemAsync('encryption-' + await scope, JSON.stringify(value), keyOptions); },
38
+ async readRecoveryKey() { return (await readEncryption())?.key ?? SecureStore.getItemAsync('recovery-' + await scope, keyOptions); },
39
+ async writeRecoveryKey(value) { await SecureStore.setItemAsync('recovery-' + await scope, value, keyOptions); },
40
+ };
41
+ }
@@ -0,0 +1,3 @@
1
+ import type { MessagingInboxPreferences } from '@robono/messaging';
2
+ /** A small account-scoped appearance preference; contains no messages or credentials. */
3
+ export declare function createExpoInboxPreferences(endpoint: string, userId: string, namespace?: string): MessagingInboxPreferences;
@@ -0,0 +1,9 @@
1
+ import * as FS from 'expo-file-system/legacy';
2
+ import { storageDigest } from './expo-storage-digest.js';
3
+ /** A small account-scoped appearance preference; contains no messages or credentials. */
4
+ export function createExpoInboxPreferences(endpoint, userId, namespace = 'default') {
5
+ const file = async () => { if (!FS.documentDirectory)
6
+ throw Error('Account settings storage is unavailable.'); return FS.documentDirectory + 'robono-inbox-' + await storageDigest(JSON.stringify([endpoint, namespace, userId])) + '.json'; };
7
+ return { async read() { const path = await file(); if (!(await FS.getInfoAsync(path)).exists)
8
+ return null; const value = JSON.parse(await FS.readAsStringAsync(path)); return typeof value.showSelf === 'boolean' ? value.showSelf : null; }, async write(showSelf) { await FS.writeAsStringAsync(await file(), JSON.stringify({ showSelf })); } };
9
+ }
@@ -1,6 +1,6 @@
1
1
  import { allocateMessagingCache, removeMessagingCacheUri } from './expo-cache.js';
2
2
  import { MessagingError } from '@robono/messaging';
3
- import { MessagingMediaAccess } from './media-access.js';
3
+ import { MessagingMediaAccess, isRemoteMessagingAsset } from './media-access.js';
4
4
  import { awaitMediaScreening } from './media-screening';
5
5
  import { AppState } from 'react-native';
6
6
  import { prepareRecordingPermission } from './recording-permission.js';
@@ -313,7 +313,7 @@ export function createExpoMessagingStorage(options) {
313
313
  check(context.signal);
314
314
  if (message.deleted)
315
315
  throw Error('This attachment is no longer available.');
316
- if (options.streaming === false || !['voice', 'video'].includes(message.kind) || !['robono-r2:', 'bridge:'].some(prefix => message.media?.assetId.startsWith(prefix)))
316
+ if (options.streaming === false || !['voice', 'video'].includes(message.kind) || !isRemoteMessagingAsset(message.media?.assetId ?? ''))
317
317
  return null;
318
318
  const plan = await playbackPlan(message, context.signal);
319
319
  // The native player requests byte ranges directly from the same private,
@@ -373,7 +373,7 @@ export function createExpoMessagingStorage(options) {
373
373
  if (message.deleted)
374
374
  throw Error('This attachment is no longer available.');
375
375
  const grant = message.attachmentPreview;
376
- const fresh = grant && grant.messageId === message.id && grant.conversationId === message.conversationId && grant.assetId === message.media?.assetId && Number.isFinite(grant.expiresAt) && grant.expiresAt > Date.now() + 5000 && grant.expiresAt <= Date.now() + 60000 && Number.isSafeInteger(grant.byteSize) && grant.byteSize > 0 && grant.byteSize <= 131072;
376
+ const fresh = grant && grant.messageId === message.id && grant.conversationId === message.conversationId && grant.assetId === message.media?.assetId && Number.isFinite(grant.expiresAt) && grant.expiresAt > Date.now() + 5000 && grant.expiresAt <= Date.now() + 60000 && Number.isSafeInteger(grant.byteSize) && grant.byteSize > 0 && grant.byteSize <= (message.media?.assetId.startsWith('bridge:') ? 204800 : 131072);
377
377
  const plan = fresh ? { url: grant.url, media: { assetId: grant.assetId, mimeType: 'image/jpeg', fileName: 'preview.jpg', byteSize: grant.byteSize } } : await request('thumbnail', { conversationId: message.conversationId, messageId: message.id }, context.signal);
378
378
  if (!plan)
379
379
  return null;
@@ -1,4 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { createExpoInboxPreferences } from './expo-inbox-preferences.js';
3
+ import { useDirectoryNavigation, MessagingDirectoryConversation } from './directory-navigation.js';
2
4
  import { renderNativeCallVideo } from '@robono/calling-react-native/native-video';
3
5
  import { createInboxViewMemory } from './inbox-view.js';
4
6
  import { MessagingPublicRooms } from './public-rooms.js';
@@ -36,7 +38,7 @@ export function createExpoMessenger(options) {
36
38
  void availability?.stop(); };
37
39
  const activitySubscription = availability ? AppState.addEventListener('change', activityChanged) : undefined;
38
40
  activityChanged(AppState.currentState);
39
- const inbox = new MessagingInboxClient({ request: createMessagingTransport({ ...options, url: endpoint.href }) });
41
+ const inbox = new MessagingInboxClient({ request: createMessagingTransport({ ...options, url: endpoint.href }), userId: options.userId, preferences: options.persistence === false ? undefined : createExpoInboxPreferences(endpoint.href, options.userId, options.namespace) });
40
42
  const storage = createExpoMessagingStorage({ url: media.href, getAccessToken: options.getAccessToken, ...(options.fetch ? { fetch: options.fetch } : {}) });
41
43
  const outgoing = expoOutbox(client);
42
44
  if (outgoing)
@@ -152,7 +154,8 @@ function ExpoMessengerContent({ inbox, contacts = emptyContacts, initialConversa
152
154
  const selected = selectedConversation === undefined ? internal : selectedConversation;
153
155
  // Declarative navigation loads the selected conversation itself. Internal open()
154
156
  // changes the client synchronously, so this never opens it a second time.
155
- useLayoutEffect(() => { if (!selected) {
157
+ useLayoutEffect(() => { if (selected)
158
+ directoryNavigation.cancel(); if (!selected) {
156
159
  props.client.stop();
157
160
  return;
158
161
  } if (props.client.getSnapshot().conversationId !== selected.id)
@@ -183,16 +186,18 @@ function ExpoMessengerContent({ inbox, contacts = emptyContacts, initialConversa
183
186
  setSelected(null); },
184
187
  } : props.conversationActions;
185
188
  const open = (row, messageId) => {
189
+ directoryNavigation.cancel();
186
190
  setShowMaps(false);
187
191
  setSelected(row);
188
192
  void props.client.open(row.id).then(async () => { if (messageId && props.client.getSnapshot().conversationId === row.id)
189
193
  await props.client.focusMessage(messageId); }).catch(() => { });
190
194
  };
195
+ const directoryNavigation = useDirectoryNavigation({ directory: props.directory, onOpenDirectoryContact: props.onOpenDirectoryContact, scope: inbox, userId: props.userId, active: props.active, onOpen: open });
191
196
  useEffect(() => { void notifications?.start(async (id, message) => { await inbox.refresh(); const row = inbox.getSnapshot().conversations.find(c => c.id === id); if (row)
192
197
  open(row, message); }).catch(() => { }); }, [notifications, inbox]);
193
198
  const notificationAccount = notifications ? { name: props.account?.name ?? 'Your account', ...props.account, onEnableNotifications: () => notifications.enable() } : props.account;
194
199
  const account = calling?.deviceCheck ? { name: 'Your account', ...notificationAccount, deviceCheck: calling.deviceCheck, renderCallPreview: (stream) => renderNativeCallVideo({ stream, local: true, style: { width: '100%', height: '100%' } }) } : notificationAccount;
195
- const knownContact = contacts[selected?.contactId ?? ''];
196
- const contact = useMemo(() => selected?.contactId === props.userId ? { name: 'Notes to self' } : selected?.kind === 'group' ? { name: selected.name ?? 'Group' } : knownContact ?? { name: selected?.contactId ?? 'Chat' }, [selected?.contactId, selected?.kind, selected?.name, props.userId, knownContact]);
197
- return _jsxs(View, { style: { flex: 1, minHeight: 0 }, children: [_jsx(MessengerMapsNotice, { error: mapConnection.error, retry: mapConnection.retry }), showMaps && maps ? _jsx(RobonoMaps, { interfaceLocale: mapsLocale, workspace: maps, contacts: contacts, onClose: () => setShowMaps(false) }) : _jsx(ExpoMessagingScreen, { ...props, conversationActions: conversationActions, account: account, contact: contact, participants: props.participants ?? contacts, extras: selected ? props.extras : undefined, callActions: selected && selected.contactId !== props.userId ? { ...autoCalls, ...props.callActions, phoneNumber: contacts[selected.contactId ?? '']?.phoneNumber ?? props.callActions?.phoneNumber } : undefined, onBack: () => { props.client.stop(); setSelected(null); void inbox.refresh().catch(() => { }); }, renderConversation: screen => selected ? _jsx(MessagingCallingScreen, { ...screen, onCall: screen.callActions?.voice, onVideoCall: screen.callActions?.video, callLabel: "Internet call", unansweredCallId: callState.unanswered?.conversationId === selected.id ? callState.unanswered.id : undefined, onDismissCallMessage: calling?.dismissUnanswered }) : _jsxs(MessagingProvider, { ...screen, appearance: props.appearance ?? inboxState.appearance ?? undefined, children: [_jsx(MessagingInbox, { manageUpdates: false, directory: props.directory, onOpenDirectoryContact: props.onOpenDirectoryContact, viewMemory: inboxMemory, client: inbox, userId: props.userId, contacts: contacts, companyName: props.companyName, appearance: props.appearance, active: props.active !== false, headerActions: _jsx(MessagingAccountMenu, { onNewConversation: props.onNewConversation, onPublicRooms: inboxState.publicRoomsAvailable ? () => setPublicRooms(true) : undefined, onMaps: mapsAvailable ? () => setShowMaps(true) : undefined, onNewGroup: inboxState.groupCreationAvailable ? () => setNewGroup(true) : undefined }), onSelect: open, onDeleted: id => props.client.forgetConversation(id) }), publicRooms && _jsx(MessagingPublicRooms, { inbox: inbox, accent: (props.appearance ?? inboxState.appearance ?? defaultMessagingSettings().appearance).colors.accent, createRequestId: () => props.client.createForwardId(), onClose: () => setPublicRooms(false), onJoined: (id, name) => { setPublicRooms(false); open(inbox.getSnapshot().conversations.find(c => c.id === id) ?? { id, kind: 'group', name, contactId: null, lastMessage: null, unreadCount: 0, canSend: true }); } }), newGroup && _jsx(MessagingGroupEditor, { client: props.client, inbox: inbox, userId: props.userId, contacts: contacts, groups: inboxState.groups, accent: (props.appearance ?? inboxState.appearance ?? defaultMessagingSettings().appearance).colors.accent, onClose: () => setNewGroup(false), onSaved: (id, name) => { setNewGroup(false); const row = inbox.getSnapshot().conversations.find(c => c.id === id) ?? { id, kind: 'group', name, contactId: null, lastMessage: null, unreadCount: 0, canSend: true }; open(row); } }), props.inboxOverlay] }) }), _jsx(ExpoMessengerCalls, { calling: calling, state: callState })] });
200
+ const knownContact = contacts[selected?.contactId ?? ''] ?? props.directory?.find(entry => entry.contactId === selected?.contactId);
201
+ const contact = useMemo(() => selected?.contactId === props.userId ? { name: 'Me', avatarUrl: props.account?.avatarUrl } : selected?.kind === 'group' ? { name: selected.name ?? 'Group' } : knownContact ?? { name: selected?.contactId ?? 'Chat' }, [selected?.contactId, selected?.kind, selected?.name, props.userId, knownContact, props.account?.avatarUrl]);
202
+ return _jsxs(View, { style: { flex: 1, minHeight: 0 }, children: [_jsx(MessengerMapsNotice, { error: mapConnection.error, retry: mapConnection.retry }), showMaps && maps ? _jsx(RobonoMaps, { interfaceLocale: mapsLocale, workspace: maps, contacts: contacts, onClose: () => setShowMaps(false) }) : _jsx(ExpoMessagingScreen, { ...props, initialAppearance: props.initialAppearance ?? inboxState.appearance ?? undefined, conversationActions: conversationActions, account: account, contact: contact, participants: props.participants ?? contacts, extras: selected ? props.extras : undefined, callActions: selected && selected.contactId !== props.userId ? { ...autoCalls, ...props.callActions, phoneNumber: contacts[selected.contactId ?? '']?.phoneNumber ?? props.callActions?.phoneNumber } : undefined, onBack: () => { props.client.stop(); setSelected(null); void inbox.refresh().catch(() => { }); }, renderConversation: screen => directoryNavigation.selection ? _jsx(MessagingDirectoryConversation, { entry: directoryNavigation.selection, busy: directoryNavigation.busy, error: directoryNavigation.error, appearance: props.appearance ?? inboxState.appearance ?? defaultMessagingSettings().appearance, onBack: directoryNavigation.cancel, onRetry: () => void directoryNavigation.open(directoryNavigation.selection) }) : selected ? _jsx(MessagingCallingScreen, { ...screen, onCall: screen.callActions?.voice, onVideoCall: screen.callActions?.video, callLabel: "Internet call", unansweredCallId: callState.unanswered?.conversationId === selected.id ? callState.unanswered.id : undefined, onDismissCallMessage: calling?.dismissUnanswered }) : _jsxs(MessagingProvider, { ...screen, appearance: props.appearance ?? inboxState.appearance ?? undefined, children: [_jsx(MessagingInbox, { selfAvatarUrl: props.account?.avatarUrl, onNewConversation: props.onNewConversation, onDirectorySelect: entry => { props.client.stop(); setSelected(null); void directoryNavigation.open(entry); }, manageUpdates: false, directory: props.directory, onOpenDirectoryContact: props.onOpenDirectoryContact, viewMemory: inboxMemory, client: inbox, userId: props.userId, contacts: contacts, companyName: props.companyName, appearance: props.appearance, active: props.active !== false, headerActions: _jsx(MessagingAccountMenu, { inbox: inbox, onNewConversation: props.onNewConversation, onPublicRooms: inboxState.publicRoomsAvailable ? () => setPublicRooms(true) : undefined, onMaps: mapsAvailable ? () => setShowMaps(true) : undefined, onNewGroup: inboxState.groupCreationAvailable ? () => setNewGroup(true) : undefined }), onSelect: open, onDeleted: id => props.client.forgetConversation(id) }), publicRooms && _jsx(MessagingPublicRooms, { inbox: inbox, accent: (props.appearance ?? inboxState.appearance ?? defaultMessagingSettings().appearance).colors.accent, createRequestId: () => props.client.createForwardId(), onClose: () => setPublicRooms(false), onJoined: (id, name) => { setPublicRooms(false); open(inbox.getSnapshot().conversations.find(c => c.id === id) ?? { id, kind: 'group', name, contactId: null, lastMessage: null, unreadCount: 0, canSend: true }); } }), newGroup && _jsx(MessagingGroupEditor, { client: props.client, inbox: inbox, userId: props.userId, contacts: contacts, groups: inboxState.groups, accent: (props.appearance ?? inboxState.appearance ?? defaultMessagingSettings().appearance).colors.accent, onClose: () => setNewGroup(false), onSaved: (id, name) => { setNewGroup(false); const row = inbox.getSnapshot().conversations.find(c => c.id === id) ?? { id, kind: 'group', name, contactId: null, lastMessage: null, unreadCount: 0, canSend: true }; open(row); } }), props.inboxOverlay] }) }), _jsx(ExpoMessengerCalls, { calling: calling, state: callState })] });
198
203
  }
@@ -0,0 +1,3 @@
1
+ import React from "react";
2
+ import { type MessagingReviewInboxProps } from "./reviews.js";
3
+ export declare function ExpoMessageReviewInbox(props: Omit<MessagingReviewInboxProps, "renderMedia">): React.JSX.Element;
@@ -0,0 +1,40 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useEffect } from "react";
3
+ import { Pressable, Text, View } from "react-native";
4
+ import { useAudioPlayer, useAudioPlayerStatus } from "expo-audio";
5
+ import { useVideoPlayer } from "expo-video";
6
+ import { MessengerVideoView } from "./messenger-video-view.js";
7
+ import { MessagingReviewInbox, } from "./reviews.js";
8
+ function ReviewVoice({ url }) {
9
+ const player = useAudioPlayer({ uri: url }), status = useAudioPlayerStatus(player);
10
+ useEffect(() => {
11
+ if (status.didJustFinish) {
12
+ player.pause();
13
+ void player.seekTo(0);
14
+ }
15
+ }, [player, status.didJustFinish]);
16
+ const label = !status.isLoaded
17
+ ? "Loading recording…"
18
+ : status.playing
19
+ ? "Pause recording"
20
+ : "Play recording";
21
+ return (_jsx(View, { children: _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: label, disabled: !status.isLoaded, onPress: () => {
22
+ if (status.playing)
23
+ player.pause();
24
+ else
25
+ player.play();
26
+ }, style: { padding: 14, minHeight: 44 }, children: _jsx(Text, { style: { color: "#17251c" }, children: label }) }) }));
27
+ }
28
+ function ReviewVideo({ url }) {
29
+ const player = useVideoPlayer(url, (p) => {
30
+ p.loop = false;
31
+ });
32
+ return (_jsx(MessengerVideoView, { player: player, nativeControls: true, style: { width: "100%", height: 240 } }));
33
+ }
34
+ export function ExpoMessageReviewInbox(props) {
35
+ return (_jsx(MessagingReviewInbox, { ...props, renderMedia: ({ url, kind }) => kind === "voice"
36
+ ? _jsx(ReviewVoice, { url: url })
37
+ : kind === "video"
38
+ ? _jsx(ReviewVideo, { url: url })
39
+ : _jsx(Text, { children: "This file type needs a host-provided private viewer." }) }));
40
+ }
@@ -82,6 +82,7 @@ function VoicePlayer({ file, audio, design, inline, draft, autoPlay = false }) {
82
82
  const reportPlayback = useContext(MediaPlayback);
83
83
  const player = useAudioPlayer(source, { updateInterval: 100, downloadFirst: false, preferredForwardBufferDuration: 5, keepAudioSessionActive: true });
84
84
  const mediaReady = useContext(MediaReadiness), recover = useContext(StreamRecovery);
85
+ const completed = useRef(false), resetting = useRef(null);
85
86
  const recovered = useRef(false), lastPosition = useRef(file.resumeAtMs ?? 0), playIntent = useRef(file.autoPlay ?? autoPlay);
86
87
  const [loaded, setLoaded] = useState(false);
87
88
  autoPlay = file.autoPlay ?? autoPlay;
@@ -108,6 +109,8 @@ function VoicePlayer({ file, audio, design, inline, draft, autoPlay = false }) {
108
109
  return true;
109
110
  };
110
111
  useEffect(() => {
112
+ player.loop = false;
113
+ completed.current = false;
111
114
  const scope = voiceScope();
112
115
  current.current = scope;
113
116
  let started = false, reported = false, cancelled = false, autoPreparing = autoPlay;
@@ -143,22 +146,39 @@ function VoicePlayer({ file, audio, design, inline, draft, autoPlay = false }) {
143
146
  fail(Error('Could not resume the recording.')); }); };
144
147
  setLoaded(player.isLoaded);
145
148
  restorePaused();
146
- const subscription = player.addListener('playbackStatusUpdate', status => { if (!scope.alive)
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' });
150
- playIntent.current = false;
151
- lastPosition.current = 0;
152
- setPosition(0);
153
- setPlaying(false);
154
- void player.seekTo(0).catch(() => { });
155
- void releaseVoice(scope);
156
- return;
157
- } if ('error' in status && status.error) {
158
- if (!recoverStream())
159
- fail(Error('The recording could not be played. Try again.'));
160
- return;
161
- } restorePaused(); begin(); });
149
+ const subscription = player.addListener('playbackStatusUpdate', status => {
150
+ if (!scope.alive)
151
+ return;
152
+ setLoaded(status.isLoaded);
153
+ if (status.didJustFinish) {
154
+ if (completed.current)
155
+ return;
156
+ completed.current = true;
157
+ cancelled = true;
158
+ started = true;
159
+ scope.epoch++;
160
+ clearTimeout(startupTimeout);
161
+ if (!draft)
162
+ reportPlayback(file.uri, { positionMs: player.duration * 1000, durationMs: player.duration * 1000, playing: false, ended: true, activeView: AppState.currentState === 'active' });
163
+ // Seeking a still-running native player to zero can restart it. Stop first;
164
+ // ordinary Pause never takes this path or changes the playback position.
165
+ playIntent.current = false;
166
+ player.pause();
167
+ lastPosition.current = 0;
168
+ setPosition(0);
169
+ setPlaying(false);
170
+ resetting.current = player.seekTo(0).catch(() => { });
171
+ void releaseVoice(scope);
172
+ return;
173
+ }
174
+ if ('error' in status && status.error) {
175
+ if (!recoverStream())
176
+ fail(Error('The recording could not be played. Try again.'));
177
+ return;
178
+ }
179
+ restorePaused();
180
+ begin();
181
+ });
162
182
  voiceStops.add(stop);
163
183
  if (autoPlay) {
164
184
  scope.busy = true;
@@ -184,7 +204,7 @@ function VoicePlayer({ file, audio, design, inline, draft, autoPlay = false }) {
184
204
  } });
185
205
  }
186
206
  const timer = setInterval(() => {
187
- if (!scope.alive)
207
+ if (!scope.alive || completed.current)
188
208
  return;
189
209
  if (!draft)
190
210
  reportPlayback(file.uri, { positionMs: player.currentTime * 1000, durationMs: player.duration * 1000, playing: player.playing, activeView: AppState.currentState === 'active', rate: player.playbackRate });
@@ -232,8 +252,11 @@ function VoicePlayer({ file, audio, design, inline, draft, autoPlay = false }) {
232
252
  await releaseVoice(scope);
233
253
  return;
234
254
  }
235
- if (player.duration > 0 && player.currentTime >= player.duration - .05)
255
+ if (completed.current) {
256
+ await resetting.current;
236
257
  await player.seekTo(0);
258
+ completed.current = false;
259
+ }
237
260
  playIntent.current = true;
238
261
  player.play();
239
262
  }
@@ -252,7 +275,7 @@ function VoicePlayer({ file, audio, design, inline, draft, autoPlay = false }) {
252
275
  const duration = file.durationMs ?? player.duration * 1000;
253
276
  if (draft)
254
277
  return _jsx(VoiceDraftPlayback, { compact: draft.compact, appearance: design, playing: playing, positionMs: position, durationMs: duration, waveform: draft.waveform, onToggle: () => void toggle(), onRemove: draft.onRemove, disabled: draft.disabled, error: error });
255
- return _jsx(VoicePlayback, { message: inline?.message, mine: inline?.mine, heard: inline?.heard, onPlayed: inline?.onPlayed, background: inline?.background, ink: inline?.ink ?? c.foreground, accent: inline?.accent ?? c.accent, waveform: inline?.waveform, showWaveform: inline?.showWaveform, footer: inline?.footer, onLongPress: inline?.onLongPress, durationMs: duration, positionMs: position, playing: playing, loading: !!file.stream && !loaded && !error, error: error, onToggle: () => void toggle(), onSeek: ms => { lastPosition.current = Math.max(0, Math.min(duration, ms)); void player.seekTo(lastPosition.current / 1000).catch(() => { if (!recoverStream())
278
+ return _jsx(VoicePlayback, { message: inline?.message, mine: inline?.mine, heard: inline?.heard, onPlayed: inline?.onPlayed, background: inline?.background, ink: inline?.ink ?? c.foreground, accent: inline?.accent ?? c.accent, waveform: inline?.waveform, showWaveform: inline?.showWaveform, footer: inline?.footer, onLongPress: inline?.onLongPress, durationMs: duration, positionMs: position, playing: playing, loading: !!file.stream && !loaded && !error, error: error, onToggle: () => void toggle(), onSeek: ms => { completed.current = false; lastPosition.current = Math.max(0, Math.min(duration, ms)); void player.seekTo(lastPosition.current / 1000).catch(() => { if (!recoverStream())
256
279
  setError(uiText("Could not seek. Try again.")); }); } });
257
280
  }
258
281
  function VideoPlayer({ file, audio, posterUri }) {
@@ -465,11 +488,21 @@ function ExpoMessagingScreenContent({ storage, audioSession, renderConversation,
465
488
  controller.restorePrepared(media.assetId, copy, kind);
466
489
  return copy;
467
490
  }, [controller, recorder, props.client, outbox, audioSession]);
468
- const prepare = async (kind, media) => { await restore(media, kind); const owner = recorder.getPrepared(media.assetId) ? recorder : controller; if (!owner.getPrepared(media.assetId))
469
- return media; const uploaded = await owner.uploadPrepared(media.assetId, kind); return uploaded; };
470
- useEffect(() => props.client.setAttachmentPreparer(async (content) => { if (!content.media || content.kind === 'text' || content.kind === 'poll' || !await restore(content.media, content.kind))
471
- throw Error('The saved attachment is unavailable. Remove it and choose it again.'); return { ...content, media: await prepare(content.kind, content.media) }; }), [props.client, controller, recorder, outbox]);
472
491
  const thumbnails = useMemo(() => createExpoThumbnails(recent.storage, id => controller.getPrepared(id) ?? recorder.getPrepared(id), createExpoMessagingDevice(audioSession).remove), [recent, controller, recorder, audioSession]);
492
+ const prepare = async (kind, media) => {
493
+ await restore(media, kind);
494
+ const owner = recorder.getPrepared(media.assetId) ? recorder : controller;
495
+ if (!owner.getPrepared(media.assetId))
496
+ return media;
497
+ const conversationId = props.client.getSnapshot().conversationId;
498
+ const preparedPreview = thumbnails.preview({ id: 'pending:' + media.assetId, conversationId, kind, media });
499
+ const uploaded = await owner.uploadPrepared(media.assetId, kind);
500
+ if (props.client.getSnapshot().conversationId === conversationId)
501
+ thumbnails.retainUpload(conversationId, uploaded, await preparedPreview);
502
+ return uploaded;
503
+ };
504
+ useEffect(() => props.client.setAttachmentPreparer(async (content) => { if (!content.media || content.kind === 'text' || content.kind === 'poll' || !await restore(content.media, content.kind))
505
+ throw Error('The saved attachment is unavailable. Remove it and choose it again.'); return { ...content, media: await prepare(content.kind, content.media) }; }), [props.client, controller, recorder, outbox, thumbnails]);
473
506
  const thumbnailAccess = JSON.stringify([state.settings?.enabled, state.settings?.features, state.conversation?.canSend, !!state.error]);
474
507
  useEffect(() => () => thumbnails.clear(), [thumbnails, state.conversationId, thumbnailAccess, props.active]);
475
508
  useEffect(() => { const sub = AppState.addEventListener('change', value => { if (value !== 'active')
@@ -553,8 +586,8 @@ function ExpoMessagingScreenContent({ storage, audioSession, renderConversation,
553
586
  return ready ? _jsx(ExpoSocialPlayer, { ...ui }) : null;
554
587
  }, [audioSession]);
555
588
  useEffect(() => saved?.bindDownload(async (m) => { const device = createExpoMessagingDevice(audioSession), file = await storage.download(m, { signal: AbortSignal.timeout(120000), onProgress: () => { } }); return { file, release: () => device.remove(file) }; }), [saved, storage, audioSession]);
556
- const attachmentPreview = useCallback(async (m, options) => { if (m.media && m.kind !== 'text' && m.kind !== 'poll')
557
- await restore(m.media, m.kind); return thumbnails.preview(m, options); }, [restore, thumbnails]);
589
+ const attachmentPreview = useMemo(() => Object.assign(async (m, options) => { if (m.media && m.kind !== 'text' && m.kind !== 'poll')
590
+ await restore(m.media, m.kind); return thumbnails.preview(m, options); }, { peek: thumbnails.peek }), [restore, thumbnails]);
558
591
  const defaultQuoteReady = useCallback(() => { if (Platform.OS === 'android')
559
592
  Vibration.vibrate(8);
560
593
  else if (Platform.OS === 'ios')
@@ -11,4 +11,8 @@ export declare function createExpoThumbnails(storage: MessagingMediaStorage, loc
11
11
  uri?: string;
12
12
  waveform?: number[];
13
13
  } | undefined;
14
+ retainUpload: (conversationId: string, media: NonNullable<MessagingMessage["media"]>, value: {
15
+ uri?: string;
16
+ waveform?: number[];
17
+ }) => void;
14
18
  };
@@ -1,3 +1,4 @@
1
+ import { isSmallMessagingJpeg, useSmallOriginalPreview } from './media-access.js';
1
2
  import { MessagingPreviewCache } from './preview-cache.js';
2
3
  import * as ImageManipulator from 'expo-image-manipulator';
3
4
  import * as VideoThumbnails from 'expo-video-thumbnails';
@@ -7,7 +8,7 @@ import * as FS from 'expo-file-system/legacy';
7
8
  export function createExpoThumbnails(storage, local, remove) {
8
9
  const cache = new MessagingPreviewCache();
9
10
  const clear = () => cache.clear();
10
- const keyFor = (message) => JSON.stringify([message.conversationId, message.media?.assetId, message.revision, message.media]);
11
+ const keyFor = (message) => JSON.stringify([message.conversationId, message.media?.assetId, message.revision ?? 0, message.media]);
11
12
  function preview(message, options) {
12
13
  const media = message.media;
13
14
  if (!media || message.deleted)
@@ -29,7 +30,7 @@ export function createExpoThumbnails(storage, local, remove) {
29
30
  return {};
30
31
  try {
31
32
  let dedicated = false;
32
- if (!file && storage.thumbnail) {
33
+ if (!file && storage.thumbnail && !useSmallOriginalPreview(message)) {
33
34
  file = await storage.thumbnail(message, { signal, onProgress: () => { } }) ?? undefined;
34
35
  dedicated = !!file;
35
36
  downloaded = !!file;
@@ -42,6 +43,12 @@ export function createExpoThumbnails(storage, local, remove) {
42
43
  }
43
44
  if (signal.aborted)
44
45
  return {};
46
+ // A server thumbnail or small original JPEG is already bounded. Re-encoding adds
47
+ // another native decode/encode before the first visible frame.
48
+ if (dedicated || message.kind === 'image' && isSmallMessagingJpeg(file)) {
49
+ const base64 = await FS.readAsStringAsync(file.uri, { encoding: FS.EncodingType.Base64 });
50
+ return signal.aborted ? {} : { uri: 'data:image/jpeg;base64,' + base64 };
51
+ }
45
52
  if (message.kind === 'video' && !dedicated)
46
53
  poster = (await VideoThumbnails.getThumbnailAsync(file.uri, { time: 0, quality: .6 })).uri;
47
54
  const result = await ImageManipulator.manipulateAsync(poster ?? file.uri, [{ resize: { width: 480 } }], { compress: .7, format: ImageManipulator.SaveFormat.JPEG, base64: true });
@@ -58,5 +65,20 @@ export function createExpoThumbnails(storage, local, remove) {
58
65
  });
59
66
  }
60
67
  // Uploaded IDs get their own authorized preview; never alias access between assets.
61
- return { preview, clear, peek: (message) => message.deleted ? undefined : cache.peek(keyFor(message)) };
68
+ const peek = (message) => {
69
+ if (message.deleted)
70
+ return undefined;
71
+ const cached = cache.peek(keyFor(message));
72
+ if (cached)
73
+ return cached;
74
+ const file = message.kind === 'image' && message.media ? local(message.media.assetId) : undefined;
75
+ return file ? { uri: file.uri } : undefined;
76
+ };
77
+ // Only the owning upload can transfer its prepared preview to the accepted
78
+ // asset. Received assets continue through their own authorization path.
79
+ const retainUpload = (conversationId, media, value) => {
80
+ if (value.uri)
81
+ void cache.get(keyFor({ conversationId, media }), async () => value);
82
+ };
83
+ return { preview, clear, peek, retainUpload };
62
84
  }
package/dist/expo.d.ts CHANGED
@@ -5,3 +5,7 @@ export { MessagingConnectionState, type MessagingConnectionStateProps, Messaging
5
5
  export type { MessagingDirectoryContact, MessagingDirectoryOptions } from './contact-directory.js';
6
6
  export { createExpoBridgeMessenger } from './expo-bridge.js';
7
7
  export { configureExpoMessagingCache, maintainExpoMessagingCache, type MessagingDiskCacheLimits, type MessagingCacheMaintenanceResult } from './expo-cache.js';
8
+ export { ExpoMessageReviewInbox } from './expo-reviews.js';
9
+ export { createExpoMessagingBackupCrypto } from './expo-backup-crypto.js';
10
+ export { createExpoMessagingBackupSettings } from './expo-backup-settings.js';
11
+ export { createExpoMessagingBackupPasskeys } from './expo-backup-passkeys.js';
package/dist/expo.js CHANGED
@@ -4,3 +4,7 @@ export { MessagingPopup } from './popup.js';
4
4
  export { MessagingConnectionState, MessagingSignIn, MessagingPhoneInput, MessagingChoicePicker } from './sign-in.js';
5
5
  export { createExpoBridgeMessenger } from './expo-bridge.js';
6
6
  export { configureExpoMessagingCache, maintainExpoMessagingCache } from './expo-cache.js';
7
+ export { ExpoMessageReviewInbox } from './expo-reviews.js';
8
+ export { createExpoMessagingBackupCrypto } from './expo-backup-crypto.js';
9
+ export { createExpoMessagingBackupSettings } from './expo-backup-settings.js';
10
+ export { createExpoMessagingBackupPasskeys } from './expo-backup-passkeys.js';
package/dist/forward.js CHANGED
@@ -36,7 +36,7 @@ export function MessagingForward({ messages, client, appearance, participants =
36
36
  setError('');
37
37
  try {
38
38
  for (const message of messages) {
39
- const key = row.id + ':' + message.id;
39
+ const key = row.id + ':' + message.id + ':' + (message.part ?? 'whole');
40
40
  if (done.current.has(key))
41
41
  continue;
42
42
  let id = attempts.current.get(key);
@@ -44,7 +44,7 @@ export function MessagingForward({ messages, client, appearance, participants =
44
44
  id = client.createForwardId();
45
45
  attempts.current.set(key, id);
46
46
  }
47
- await client.forwardMessage(message.id, row.id, id);
47
+ await client.forwardMessage(message.id, row.id, id, message.part);
48
48
  done.current.add(key);
49
49
  if (!live.current)
50
50
  return;
@@ -0,0 +1,5 @@
1
+ import type { MessagingAppearance } from '@robono/messaging';
2
+ export declare function messagingHeaderColors(design: MessagingAppearance, group: boolean): {
3
+ background: string;
4
+ foreground: string;
5
+ };
@@ -0,0 +1,7 @@
1
+ export function messagingHeaderColors(design, group) {
2
+ const screen = design.screens?.chat;
3
+ const background = group ? (screen?.groupHeaderBackground ?? '#1F5F7A') : (screen?.headerBackground ?? design.colors.accent);
4
+ const rgb = background.slice(1).match(/.{2}/g)?.map(v => parseInt(v, 16)) ?? [0, 0, 0];
5
+ const foreground = (rgb[0] * 299 + rgb[1] * 587 + rgb[2] * 114) / 1000 > 150 ? '#050505' : '#F7F7F7';
6
+ return { background, foreground: (group ? screen?.groupHeaderText : screen?.headerText) ?? foreground };
7
+ }
package/dist/inbox.d.ts CHANGED
@@ -1,15 +1,18 @@
1
- import { type MessagingDirectoryOptions } from './contact-directory.js';
1
+ import { type MessagingDirectoryContact, type MessagingDirectoryOptions } from './contact-directory.js';
2
2
  import { type InboxViewMemory } from './inbox-view.js';
3
3
  import React from 'react';
4
4
  import { type MessagingAppearance, type MessagingInboxClient, type ConversationSummary } from '@robono/messaging';
5
5
  export interface MessagingInboxProps extends MessagingDirectoryOptions {
6
6
  client: MessagingInboxClient;
7
7
  userId: string;
8
+ selfAvatarUrl?: string;
8
9
  contacts?: Record<string, {
9
10
  name: string;
10
11
  avatarUrl?: string;
11
12
  groupEligible?: boolean;
12
13
  }>;
14
+ onNewConversation?: () => void;
15
+ onDirectorySelect?: (contact: MessagingDirectoryContact) => void;
13
16
  viewMemory?: InboxViewMemory;
14
17
  query?: string;
15
18
  onSearchChange?: (value: string) => void;
@@ -24,4 +27,4 @@ export interface MessagingInboxProps extends MessagingDirectoryOptions {
24
27
  onDeleted?: (conversationId: string) => Promise<void> | void;
25
28
  }
26
29
  /** Compact Messenger chat rows: avatar, name, last message, time and unread badge. */
27
- export declare function MessagingInbox({ client, userId, contacts, appearance, active, manageUpdates, onSelect, onDeleted, companyName, headerActions, searchText, selectedId, query: controlledQuery, onSearchChange, viewMemory, directory, onOpenDirectoryContact }: MessagingInboxProps): React.JSX.Element;
30
+ export declare function MessagingInbox({ client, userId, selfAvatarUrl, contacts, appearance, active, manageUpdates, onSelect, onDeleted, companyName, headerActions, searchText, selectedId, query: controlledQuery, onSearchChange, viewMemory, directory, onOpenDirectoryContact, onDirectorySelect, onNewConversation }: MessagingInboxProps): React.JSX.Element;