@robono/messaging-react-native 0.22.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 (71) hide show
  1. package/BRIDGE-MESSENGER.md +72 -10
  2. package/CHANGELOG.md +26 -0
  3. package/README.md +83 -4
  4. package/RobonoMessagingRuntime.podspec +14 -0
  5. package/SBOM.spdx.json +967 -295
  6. package/android/build.gradle +7 -0
  7. package/android/src/main/AndroidManifest.xml +1 -0
  8. package/android/src/main/java/com/robono/messaging/RobonoBackupCrypto.java +27 -0
  9. package/android/src/main/java/com/robono/messaging/RobonoMessagingPackage.java +11 -0
  10. package/app.plugin.cjs +8 -2
  11. package/dist/account.d.ts +4 -1
  12. package/dist/account.js +33 -11
  13. package/dist/attachment-preview.d.ts +11 -10
  14. package/dist/attachment-preview.js +15 -12
  15. package/dist/backup.d.ts +24 -0
  16. package/dist/backup.js +157 -0
  17. package/dist/brand.js +4 -4
  18. package/dist/bubble-design.js +5 -3
  19. package/dist/chat-options.d.ts +5 -1
  20. package/dist/chat-options.js +2 -2
  21. package/dist/contact-directory.d.ts +5 -1
  22. package/dist/contact-directory.js +11 -3
  23. package/dist/conversation-details.js +1 -1
  24. package/dist/delivery-bar.d.ts +2 -1
  25. package/dist/delivery-bar.js +2 -2
  26. package/dist/directory-navigation.d.ts +25 -0
  27. package/dist/directory-navigation.js +69 -0
  28. package/dist/expo-backup-crypto.d.ts +3 -0
  29. package/dist/expo-backup-crypto.js +17 -0
  30. package/dist/expo-backup-passkeys.d.ts +7 -0
  31. package/dist/expo-backup-passkeys.js +22 -0
  32. package/dist/expo-backup-settings.d.ts +4 -0
  33. package/dist/expo-backup-settings.js +41 -0
  34. package/dist/expo-bridge.d.ts +6 -0
  35. package/dist/expo-bridge.js +13 -2
  36. package/dist/expo-inbox-preferences.d.ts +3 -0
  37. package/dist/expo-inbox-preferences.js +9 -0
  38. package/dist/expo-media.js +3 -3
  39. package/dist/expo-messenger.js +10 -5
  40. package/dist/expo-notification-cleanup.js +3 -3
  41. package/dist/expo-notifications.js +7 -3
  42. package/dist/expo-reviews.d.ts +3 -0
  43. package/dist/expo-reviews.js +40 -0
  44. package/dist/expo-screen.d.ts +3 -0
  45. package/dist/expo-screen.js +87 -45
  46. package/dist/expo-thumbnails.d.ts +4 -0
  47. package/dist/expo-thumbnails.js +25 -3
  48. package/dist/expo.d.ts +4 -0
  49. package/dist/expo.js +4 -0
  50. package/dist/forward.js +2 -2
  51. package/dist/header-colors.d.ts +5 -0
  52. package/dist/header-colors.js +7 -0
  53. package/dist/inbox.d.ts +5 -2
  54. package/dist/inbox.js +25 -53
  55. package/dist/index.d.ts +8 -5
  56. package/dist/index.js +78 -36
  57. package/dist/loading-messages.d.ts +5 -0
  58. package/dist/loading-messages.js +10 -0
  59. package/dist/media-access.d.ts +8 -0
  60. package/dist/media-access.js +6 -1
  61. package/dist/media-readiness.d.ts +2 -0
  62. package/dist/media-readiness.js +1 -0
  63. package/dist/playback-reporting.d.ts +8 -0
  64. package/dist/playback-reporting.js +32 -0
  65. package/dist/popup.d.ts +6 -3
  66. package/dist/popup.js +6 -6
  67. package/dist/reviews.d.ts +15 -0
  68. package/dist/reviews.js +204 -0
  69. package/dist/scheduled.js +5 -5
  70. package/ios/RobonoBackupCrypto.m +30 -0
  71. package/package.json +21 -8
@@ -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,8 +79,10 @@ 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);
85
+ const completed = useRef(false), resetting = useRef(null);
83
86
  const recovered = useRef(false), lastPosition = useRef(file.resumeAtMs ?? 0), playIntent = useRef(file.autoPlay ?? autoPlay);
84
87
  const [loaded, setLoaded] = useState(false);
85
88
  autoPlay = file.autoPlay ?? autoPlay;
@@ -106,6 +109,8 @@ function VoicePlayer({ file, audio, design, inline, draft, autoPlay = false }) {
106
109
  return true;
107
110
  };
108
111
  useEffect(() => {
112
+ player.loop = false;
113
+ completed.current = false;
109
114
  const scope = voiceScope();
110
115
  current.current = scope;
111
116
  let started = false, reported = false, cancelled = false, autoPreparing = autoPlay;
@@ -141,20 +146,39 @@ function VoicePlayer({ file, audio, design, inline, draft, autoPlay = false }) {
141
146
  fail(Error('Could not resume the recording.')); }); };
142
147
  setLoaded(player.isLoaded);
143
148
  restorePaused();
144
- const subscription = player.addListener('playbackStatusUpdate', status => { if (!scope.alive)
145
- return; setLoaded(status.isLoaded); if (status.didJustFinish) {
146
- playIntent.current = false;
147
- lastPosition.current = 0;
148
- setPosition(0);
149
- setPlaying(false);
150
- void player.seekTo(0).catch(() => { });
151
- void releaseVoice(scope);
152
- return;
153
- } if ('error' in status && status.error) {
154
- if (!recoverStream())
155
- fail(Error('The recording could not be played. Try again.'));
156
- return;
157
- } 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
+ });
158
182
  voiceStops.add(stop);
159
183
  if (autoPlay) {
160
184
  scope.busy = true;
@@ -180,8 +204,10 @@ function VoicePlayer({ file, audio, design, inline, draft, autoPlay = false }) {
180
204
  } });
181
205
  }
182
206
  const timer = setInterval(() => {
183
- if (!scope.alive)
207
+ if (!scope.alive || completed.current)
184
208
  return;
209
+ if (!draft)
210
+ reportPlayback(file.uri, { positionMs: player.currentTime * 1000, durationMs: player.duration * 1000, playing: player.playing, activeView: AppState.currentState === 'active', rate: player.playbackRate });
185
211
  if (audio.isAvailable?.() === false)
186
212
  void stop();
187
213
  if (player.currentTime > 0)
@@ -200,7 +226,8 @@ function VoicePlayer({ file, audio, design, inline, draft, autoPlay = false }) {
200
226
  }, 150);
201
227
  const app = AppState.addEventListener('change', state => { if (state !== 'active')
202
228
  void stop(); });
203
- return () => { scope.alive = false; cancelled = true; subscription.remove(); clearTimeout(startupTimeout); clearInterval(timer); app.remove(); void stop().finally(() => voiceStops.delete(stop)); };
229
+ return () => { if (!draft)
230
+ reportPlayback(file.uri, null); scope.alive = false; cancelled = true; subscription.remove(); clearTimeout(startupTimeout); clearInterval(timer); app.remove(); void stop().finally(() => voiceStops.delete(stop)); };
204
231
  }, [player]);
205
232
  async function toggle() {
206
233
  const scope = current.current;
@@ -225,8 +252,11 @@ function VoicePlayer({ file, audio, design, inline, draft, autoPlay = false }) {
225
252
  await releaseVoice(scope);
226
253
  return;
227
254
  }
228
- if (player.duration > 0 && player.currentTime >= player.duration - .05)
255
+ if (completed.current) {
256
+ await resetting.current;
229
257
  await player.seekTo(0);
258
+ completed.current = false;
259
+ }
230
260
  playIntent.current = true;
231
261
  player.play();
232
262
  }
@@ -245,12 +275,12 @@ function VoicePlayer({ file, audio, design, inline, draft, autoPlay = false }) {
245
275
  const duration = file.durationMs ?? player.duration * 1000;
246
276
  if (draft)
247
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 });
248
- 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())
249
279
  setError(uiText("Could not seek. Try again.")); }); } });
250
280
  }
251
281
  function VideoPlayer({ file, audio, posterUri }) {
252
282
  const { text: uiText, locale: uiLocale, number: uiNumber, count: uiCount } = useRobonoLocale();
253
- const mediaReady = useContext(MediaReadiness), recover = useContext(StreamRecovery);
283
+ const mediaReady = useContext(MediaReadiness), recover = useContext(StreamRecovery), reportPlayback = useContext(MediaPlayback);
254
284
  const source = useMemo(() => file.stream ? { uri: file.uri, headers: file.stream.headers, contentType: 'progressive', useCaching: false } : file.uri, [file]);
255
285
  const player = useVideoPlayer(source, p => { p.loop = false; p.audioMixingMode = 'mixWithOthers'; if (file.stream)
256
286
  p.bufferOptions = { preferredForwardBufferDuration: 5, minBufferForPlayback: 0.5 }; });
@@ -280,7 +310,7 @@ function VideoPlayer({ file, audio, posterUri }) {
280
310
  setError(e.message); });
281
311
  let consumed = false;
282
312
  const timer = setInterval(() => { if (!alive)
283
- return; if (!consumed && player.playing && player.currentTime > 0) {
313
+ 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
314
  consumed = true;
285
315
  mediaReady('video-playing', file.uri);
286
316
  } if (player.currentTime > 0)
@@ -293,6 +323,7 @@ function VideoPlayer({ file, audio, posterUri }) {
293
323
  release = undefined;
294
324
  } }, 100);
295
325
  // Native controls must retain resume intent and respect the host's call audio session.
326
+ 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
327
  const playback = player.addListener('playingChange', ({ isPlaying }) => {
297
328
  if (recovered || !alive)
298
329
  return;
@@ -316,7 +347,7 @@ function VideoPlayer({ file, audio, posterUri }) {
316
347
  desired.current = false;
317
348
  player.pause();
318
349
  } });
319
- return () => { alive = false; clearTimeout(timeout); clearInterval(timer); listener.remove(); playback.remove(); app.remove(); try {
350
+ return () => { reportPlayback(file.uri, null); ended.remove(); alive = false; clearTimeout(timeout); clearInterval(timer); listener.remove(); playback.remove(); app.remove(); try {
320
351
  player.pause();
321
352
  }
322
353
  catch { } void release?.().catch(() => { }); };
@@ -457,11 +488,21 @@ function ExpoMessagingScreenContent({ storage, audioSession, renderConversation,
457
488
  controller.restorePrepared(media.assetId, copy, kind);
458
489
  return copy;
459
490
  }, [controller, recorder, props.client, outbox, audioSession]);
460
- const prepare = async (kind, media) => { await restore(media, kind); const owner = recorder.getPrepared(media.assetId) ? recorder : controller; if (!owner.getPrepared(media.assetId))
461
- return media; const uploaded = await owner.uploadPrepared(media.assetId, kind); return uploaded; };
462
- useEffect(() => props.client.setAttachmentPreparer(async (content) => { if (!content.media || content.kind === 'text' || content.kind === 'poll' || !await restore(content.media, content.kind))
463
- 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]);
464
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]);
465
506
  const thumbnailAccess = JSON.stringify([state.settings?.enabled, state.settings?.features, state.conversation?.canSend, !!state.error]);
466
507
  useEffect(() => () => thumbnails.clear(), [thumbnails, state.conversationId, thumbnailAccess, props.active]);
467
508
  useEffect(() => { const sub = AppState.addEventListener('change', value => { if (value !== 'active')
@@ -545,8 +586,8 @@ function ExpoMessagingScreenContent({ storage, audioSession, renderConversation,
545
586
  return ready ? _jsx(ExpoSocialPlayer, { ...ui }) : null;
546
587
  }, [audioSession]);
547
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]);
548
- const attachmentPreview = useCallback(async (m, options) => { if (m.media && m.kind !== 'text' && m.kind !== 'poll')
549
- 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]);
550
591
  const defaultQuoteReady = useCallback(() => { if (Platform.OS === 'android')
551
592
  Vibration.vibrate(8);
552
593
  else if (Platform.OS === 'ios')
@@ -606,6 +647,7 @@ function ExpoMessagingScreenContent({ storage, audioSession, renderConversation,
606
647
  return;
607
648
  } opened.current = null; message.current = null; await controller.previewLocal(file, record.message.kind, record.message); },
608
649
  };
650
+ 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
651
  const mediaReady = (stage, uri) => { const event = opened.current; if (!event || controller.getSnapshot().phase !== 'viewing' || controller.getSnapshot().file?.uri !== uri)
610
652
  return; if (stage !== 'video-frame' && message.current?.conversationId === current.current.client.getSnapshot().conversationId)
611
653
  void current.current.client.consumeMessage(event.messageId).catch(() => { }); if (event.reported.has(stage))
@@ -613,21 +655,21 @@ function ExpoMessagingScreenContent({ storage, audioSession, renderConversation,
613
655
  current.current.onMediaReady?.({ messageId: event.messageId, kind: event.kind, stage, elapsedMs: Date.now() - event.started });
614
656
  }
615
657
  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: _jsxs(MediaReadiness.Provider, { value: mediaReady, 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)
617
- 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: () => {
618
- const m = message.current;
619
- if (!m || ![...state.messages, ...(state.latestVoices ?? [])].some(row => row.id === m.id && !row.deleted))
620
- return {};
621
- const action = (kind) => {
622
- afterViewer.current = { kind, messageId: m.id, sequence: Date.now() };
623
- void controller.cancel().then(() => {
624
- // Some installed native runtimes omit onDismiss after a media modal closes.
625
- // Keep the normal event fast path; retain a recovery delay for older native runtimes.
626
- // Navigation/unmount clears the queued action, so it cannot open in another chat.
627
- if (afterViewer.current)
628
- dismissFallback.current = setTimeout(viewerDismissed, Platform.OS === 'ios' ? 500 : 250);
629
- });
630
- };
631
- return { onForward: props.client.canForward(m) ? () => action('forward') : undefined, onDelete: m.senderId === props.userId && !m.readAt && state.messageActionsAvailable ? () => action('delete') : undefined };
632
- }, 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 })] }) }) });
658
+ 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)
659
+ 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: () => {
660
+ const m = message.current;
661
+ if (!m || ![...state.messages, ...(state.latestVoices ?? [])].some(row => row.id === m.id && !row.deleted))
662
+ return {};
663
+ const action = (kind) => {
664
+ afterViewer.current = { kind, messageId: m.id, sequence: Date.now() };
665
+ void controller.cancel().then(() => {
666
+ // Some installed native runtimes omit onDismiss after a media modal closes.
667
+ // Keep the normal event fast path; retain a recovery delay for older native runtimes.
668
+ // Navigation/unmount clears the queued action, so it cannot open in another chat.
669
+ if (afterViewer.current)
670
+ dismissFallback.current = setTimeout(viewerDismissed, Platform.OS === 'ios' ? 500 : 250);
671
+ });
672
+ };
673
+ return { onForward: props.client.canForward(m) ? () => action('forward') : undefined, onDelete: m.senderId === props.userId && !m.readAt && state.messageActionsAvailable ? () => action('delete') : undefined };
674
+ }, 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
675
  }
@@ -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;
package/dist/inbox.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useDirectoryNavigation, MessagingDirectoryConversation } from './directory-navigation.js';
2
3
  import { MessagingBrand } from './brand.js';
3
4
  import { messagingScreenAppearance, messagingContrastInk, messagingAvatarStyle, messagingFriendsColors, messagingMenuColors, messagingMenuLayout } from '@robono/messaging';
4
5
  import { directoryWithoutChats, MessagingDirectoryRow } from './contact-directory.js';
@@ -10,11 +11,11 @@ import { MessageMenuRow } from './message-menu.js';
10
11
  import { InboxMessageSearch } from './inbox-search.js';
11
12
  import { MessageIcon } from './icons.js';
12
13
  import { useEffect, useRef, useState, useSyncExternalStore } from 'react';
13
- import { AppState, FlatList, Image, Platform, Pressable, ScrollView, View } from 'react-native';
14
+ import { AppState, FlatList, Image, Platform, Pressable, ScrollView, StyleSheet, View } from 'react-native';
14
15
  import { defaultMessagingSettings } from '@robono/messaging';
15
16
  import { MessagingPopup, MessagingMenuSurface, MessagingPopupHeaderBoundary, useMessagingPopupColors, messagingPopupBackdrop } from './popup.js';
16
17
  /** Compact Messenger chat rows: avatar, name, last message, time and unread badge. */
17
- export function MessagingInbox({ client, userId, contacts = {}, appearance, active = true, manageUpdates = true, onSelect, onDeleted, companyName, headerActions, searchText, selectedId, query: controlledQuery, onSearchChange, viewMemory, directory = [], onOpenDirectoryContact }) {
18
+ export function MessagingInbox({ client, userId, selfAvatarUrl, contacts = {}, appearance, active = true, manageUpdates = true, onSelect, onDeleted, companyName, headerActions, searchText, selectedId, query: controlledQuery, onSearchChange, viewMemory, directory = [], onOpenDirectoryContact, onDirectorySelect, onNewConversation }) {
18
19
  const { text: uiText, locale: uiLocale, number: uiNumber, count: uiCount } = useRobonoLocale();
19
20
  const state = useSyncExternalStore(client.subscribe, client.getSnapshot, client.getSnapshot), design = messagingScreenAppearance(appearance ?? state.appearance ?? defaultMessagingSettings().appearance), c = messagingFriendsColors(design), friends = design.screens?.friends;
20
21
  const messagingPopupColors = useMessagingPopupColors(design, 'alerts');
@@ -27,55 +28,24 @@ export function MessagingInbox({ client, userId, contacts = {}, appearance, acti
27
28
  const [localQuery, setLocalQuery] = useState(memory.query);
28
29
  const query = friends?.showSearch === false ? '' : controlledQuery ?? localQuery;
29
30
  const setQuery = (value) => { memory.query = value; (onSearchChange ?? setLocalQuery)(value); };
31
+ const [searchOpen, setSearchOpen] = useState(!!query), searchInput = useRef(null);
32
+ const closeSearch = () => { setQuery(''); setSearchOpen(false); };
33
+ useEffect(() => { if (query)
34
+ setSearchOpen(true); }, [query]);
35
+ useEffect(() => { if (searchOpen) {
36
+ const frame = requestAnimationFrame(() => searchInput.current?.focus());
37
+ return () => cancelAnimationFrame(frame);
38
+ } }, [searchOpen]);
30
39
  const scroll = useInboxScroll(memory, 'chats:' + query.trim(), state.conversations.length > 0 && !state.loading, !state.hasMore);
31
40
  const [selected, setSelected] = useState(null), [confirm, setConfirm] = useState(false), [busy, setBusy] = useState(false), [error, setError] = useState('');
32
- const avatar = messagingAvatarStyle(friends?.avatarSize ?? 40, friends?.avatarShape), rowPadding = friends?.rowSpacing === 'compact' ? 6 : friends?.rowSpacing === 'relaxed' ? 16 : 10;
33
- const title = (row) => row.contactId === userId ? uiText('Notes to self') : row.kind === 'group' ? row.name ?? 'Group' : contacts[row.contactId ?? '']?.name ?? row.contactId ?? 'Chat';
34
- const [directorySelection, setDirectorySelection] = useState(null), [directoryBusy, setDirectoryBusy] = useState(false), [directoryError, setDirectoryError] = useState('');
35
- const directoryRequest = useRef(null), directoryRef = useRef(directory);
36
- directoryRef.current = directory;
37
- const cancelDirectory = () => { directoryRequest.current?.abort(); directoryRequest.current = null; setDirectoryBusy(false); setDirectorySelection(null); setDirectoryError(''); };
38
- useEffect(() => { cancelDirectory(); return () => directoryRequest.current?.abort(); }, [client, userId]);
39
- useEffect(() => { const sub = AppState.addEventListener('change', state => { if (state !== 'active')
40
- cancelDirectory(); }); return () => sub.remove(); }, []);
41
- useEffect(() => { if (!active)
42
- cancelDirectory(); }, [active]);
43
- useEffect(() => { if (directorySelection) {
44
- const current = directory.find(c => c.id === directorySelection.id);
45
- if (!current || current.available !== directorySelection.available || current.contactId !== directorySelection.contactId)
46
- cancelDirectory();
47
- } }, [directory, directorySelection]);
48
- async function openDirectory(entry) {
49
- directoryRequest.current?.abort();
50
- setDirectorySelection(entry);
51
- setDirectoryError('');
52
- setDirectoryBusy(false);
53
- if (!entry.available || !onOpenDirectoryContact)
54
- return;
55
- const control = new AbortController();
56
- directoryRequest.current = control;
57
- setDirectoryBusy(true);
58
- try {
59
- const row = await onOpenDirectoryContact(entry, control.signal);
60
- const current = directoryRef.current.find(c => c.id === entry.id);
61
- if (control.signal.aborted || !current?.available || current.contactId !== entry.contactId)
62
- return;
63
- setDirectorySelection(null);
64
- onSelect(row);
65
- }
66
- catch (e) {
67
- if (!control.signal.aborted)
68
- setDirectoryError(e instanceof Error ? e.message : uiText('This conversation is unavailable.'));
69
- }
70
- finally {
71
- if (directoryRequest.current === control) {
72
- directoryRequest.current = null;
73
- setDirectoryBusy(false);
74
- }
75
- }
76
- }
77
- const directoryRows = directoryWithoutChats(directory, state.conversations, query);
78
- const inboxRows = [...state.conversations.filter(row => !query.trim() || [title(row), row.lastMessage?.text ?? '', searchText?.(row) ?? ''].join(' ').toLocaleLowerCase().includes(query.trim().toLocaleLowerCase())).map(chat => ({ kind: 'chat', chat })), ...directoryRows.map(entry => ({ kind: 'directory', entry }))];
41
+ const avatar = messagingAvatarStyle(friends?.avatarSize ?? 48, friends?.avatarShape), rowPadding = friends?.rowSpacing === 'compact' ? 6 : friends?.rowSpacing === 'relaxed' ? 16 : 12;
42
+ const title = (row) => row.contactId === userId ? uiText('Me') : row.kind === 'group' ? row.name ?? 'Group' : contacts[row.contactId ?? '']?.name ?? row.contactId ?? 'Chat';
43
+ const directoryNavigation = useDirectoryNavigation({ directory, onOpenDirectoryContact, scope: client, userId, active, onOpen: onSelect });
44
+ const openDirectory = (entry) => onDirectorySelect ? onDirectorySelect(entry) : directoryNavigation.open(entry);
45
+ const isSelf = (row) => row.kind === 'direct' && row.contactId === userId;
46
+ const visibleChats = state.conversations.filter(row => state.showSelf !== false || !isSelf(row)).sort((a, b) => Number(isSelf(b)) - Number(isSelf(a)));
47
+ const directoryRows = directoryWithoutChats(directory.filter(entry => entry.contactId !== userId), state.conversations, query);
48
+ const inboxRows = [...visibleChats.filter(row => !query.trim() || [title(row), row.lastMessage?.text ?? '', searchText?.(row) ?? ''].join(' ').toLocaleLowerCase().includes(query.trim().toLocaleLowerCase())).map(chat => ({ kind: 'chat', chat })), ...directoryRows.map(entry => ({ kind: 'directory', entry }))];
79
49
  const rows = useRef(new Map()), pending = useRef(null);
80
50
  const [menuVisible, setMenuVisible] = useState(false), [confirmVisible, setConfirmVisible] = useState(false), [anchor, setAnchor] = useState({ x: 12, y: 88 });
81
51
  const openOptions = (row) => { if (!state.inboxActionsAvailable)
@@ -112,18 +82,20 @@ export function MessagingInbox({ client, userId, contacts = {}, appearance, acti
112
82
  } }
113
83
  const preview = (row) => { const m = row.lastMessage; if (!m)
114
84
  return 'No messages yet'; const text = m.kind === 'text' ? m.text ?? '' : ({ voice: 'Voice message', image: 'Photo', video: 'Video', document: 'Document', poll: 'Poll' }[m.kind] ?? 'Message'); return (m.senderId === userId ? 'You: ' : '') + text; };
115
- return _jsx(MessagingTypography, { appearance: design, children: _jsxs(View, { style: { flex: 1, minHeight: 0, backgroundColor: c.background }, children: [_jsx(MessagingPopupHeaderBoundary, { children: _jsxs(View, { testID: "messaging-inbox-header", style: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', backgroundColor: friends?.headerBackground ?? c.background, minHeight: friends?.headerSize === 'compact' ? 48 : friends?.headerSize === 'roomy' ? 80 : 64, paddingHorizontal: 16, paddingTop: 4, paddingBottom: 8, gap: 8 }, children: [_jsx(MessagingBrand, { appearance: design, companyName: companyName }), headerActions] }) }), friends?.showSearch !== false && _jsxs(View, { style: { margin: 12, marginTop: 8, flexDirection: 'row', alignItems: 'center', gap: 8, borderRadius: 10, paddingHorizontal: 10, backgroundColor: c.foreground + '0b' }, children: [_jsx(MessageIcon, { name: "search", size: 20, color: c.secondary }), _jsx(TextInput, { accessibilityLabel: uiText("Search chats"), placeholder: state.globalSearchAvailable ? uiText("Search chats and messages") : uiText("Search chats"), placeholderTextColor: c.secondary, value: query, onChangeText: setQuery, maxLength: 200, autoCapitalize: "none", autoCorrect: false, style: { flex: 1, minHeight: 44, color: c.foreground, fontSize: 16 } }), !!query && _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText("Clear chat search"), onPress: () => setQuery(''), style: { width: 44, height: 44, alignItems: 'center', justifyContent: 'center' }, children: _jsx(MessageIcon, { name: "close", size: 20, color: c.secondary }) })] }), state.error && _jsxs(View, { style: { padding: 12 }, children: [_jsx(Text, { accessibilityRole: "alert", style: { color: c.foreground }, children: state.error }), _jsx(Pressable, { accessibilityRole: "button", onPress: () => void client.refresh().catch(() => { }), children: _jsx(Text, { style: { color: c.accent, paddingVertical: 8 }, children: uiText("Try again") }) })] }), query.trim() && state.globalSearchAvailable ? _jsx(InboxMessageSearch, { viewMemory: memory, client: client, query: query.trim(), appearance: { ...design, colors: c }, name: title, chats: state.conversations.filter(row => title(row).toLocaleLowerCase().includes(query.trim().toLocaleLowerCase())), onSelect: onSelect, directoryHeader: directoryRows.map(entry => _jsx(MessagingDirectoryRow, { contact: entry, appearance: design, onPress: () => void openDirectory(entry) }, entry.id)) }, userId) : _jsx(FlatList, { ...scroll, testID: "messaging-inbox-list", data: inboxRows, keyExtractor: row => row.kind === 'chat' ? 'chat:' + row.chat.id : 'directory:' + row.entry.id, contentContainerStyle: { flexGrow: 1 }, ItemSeparatorComponent: () => friends?.showDividers === false ? null : _jsx(View, { style: { height: 1, backgroundColor: c.foreground + '12', marginLeft: 64 } }), ListEmptyComponent: _jsx(Text, { style: { padding: 20, textAlign: 'center', color: c.secondary }, children: state.loading ? uiText("Loading chats…") : state.error ? '' : query ? uiText("No matching chats.") : uiText("No chats yet") }), ListFooterComponent: state.hasMore ? _jsx(Pressable, { accessibilityRole: "button", disabled: state.loading, onPress: () => void client.loadMore().catch(() => { }), children: _jsx(Text, { style: { padding: 12, textAlign: 'center', color: c.accent }, children: state.loading ? uiText("Loading…") : uiText("More chats") }) }) : null, renderItem: ({ item: row }) => {
85
+ if (directoryNavigation.selection)
86
+ return _jsx(MessagingDirectoryConversation, { entry: directoryNavigation.selection, busy: directoryNavigation.busy, error: directoryNavigation.error, appearance: design, onBack: directoryNavigation.cancel, onRetry: () => void directoryNavigation.open(directoryNavigation.selection) });
87
+ return _jsx(MessagingTypography, { appearance: design, children: _jsxs(View, { style: { flex: 1, minHeight: 0, backgroundColor: c.background }, children: [_jsx(MessagingPopupHeaderBoundary, { children: _jsxs(View, { testID: "messaging-inbox-header", style: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', backgroundColor: friends?.headerBackground ?? c.background, minHeight: friends?.headerSize === 'compact' ? 48 : friends?.headerSize === 'roomy' ? 80 : 64, paddingHorizontal: 16, paddingVertical: 8, gap: 8 }, children: [_jsx(MessagingBrand, { appearance: design, companyName: companyName }), _jsxs(View, { style: { flexDirection: 'row', alignItems: 'center', gap: 8 }, children: [friends?.showSearch !== false && _jsx(Pressable, { testID: "messaging-inbox-search-toggle", accessibilityRole: "button", accessibilityLabel: uiText('Search chats'), accessibilityState: { expanded: searchOpen }, onPress: () => searchOpen ? closeSearch() : setSearchOpen(true), style: { width: 44, height: 44, alignItems: 'center', justifyContent: 'center' }, children: _jsx(MessageIcon, { name: "search", size: 23, color: friends?.headerText ?? c.foreground }) }), headerActions] })] }) }), friends?.showSearch !== false && searchOpen && _jsxs(View, { testID: "messaging-inbox-search", style: { minHeight: 46, marginHorizontal: 12, marginTop: 2, marginBottom: 4, flexDirection: 'row', alignItems: 'center', gap: 8, borderRadius: 23, borderWidth: 1, borderColor: c.background, paddingHorizontal: 12, backgroundColor: c.foreground + '26' }, children: [_jsx(MessageIcon, { name: "search", size: 18, color: c.secondary }), _jsx(TextInput, { ref: searchInput, accessibilityLabel: uiText("Search chats"), placeholder: uiText("Search chats"), placeholderTextColor: c.secondary, value: query, onChangeText: setQuery, maxLength: 200, autoCapitalize: "none", autoCorrect: false, style: { flex: 1, minWidth: 0, minHeight: 44, paddingVertical: 8, color: c.foreground, fontSize: 15 } }), _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText("Close chat search"), onPress: closeSearch, style: { width: 44, height: 44, alignItems: 'center', justifyContent: 'center' }, children: _jsx(MessageIcon, { name: "close", size: 14, color: c.secondary }) })] }), state.error && _jsxs(View, { style: { padding: 12 }, children: [_jsx(Text, { accessibilityRole: "alert", style: { color: c.foreground }, children: state.error }), _jsx(Pressable, { accessibilityRole: "button", onPress: () => void client.refresh().catch(() => { }), children: _jsx(Text, { style: { color: c.accent, paddingVertical: 8 }, children: uiText("Try again") }) })] }), query.trim() && state.globalSearchAvailable ? _jsx(InboxMessageSearch, { viewMemory: memory, client: client, query: query.trim(), appearance: { ...design, colors: c }, name: title, chats: visibleChats.filter(row => title(row).toLocaleLowerCase().includes(query.trim().toLocaleLowerCase())), onSelect: onSelect, directoryHeader: directoryRows.map(entry => _jsx(MessagingDirectoryRow, { contact: entry, appearance: design, onPress: () => void openDirectory(entry) }, entry.id)) }, userId) : _jsx(FlatList, { ...scroll, testID: "messaging-inbox-list", data: inboxRows, keyExtractor: row => row.kind === 'chat' ? 'chat:' + row.chat.id : 'directory:' + row.entry.id, contentContainerStyle: { flexGrow: 1, paddingBottom: onNewConversation ? 100 : 0 }, ItemSeparatorComponent: () => friends?.showDividers === false ? null : _jsx(View, { style: { height: StyleSheet.hairlineWidth, backgroundColor: c.foreground + '26', width: '88%', alignSelf: 'center' } }), ListEmptyComponent: _jsx(Text, { style: { padding: 20, textAlign: 'center', color: c.secondary }, children: state.loading ? uiText("Loading chats…") : state.error ? '' : query ? uiText("No matching chats.") : uiText("No chats yet") }), ListFooterComponent: state.hasMore ? _jsx(Pressable, { accessibilityRole: "button", disabled: state.loading, onPress: () => void client.loadMore().catch(() => { }), children: _jsx(Text, { style: { padding: 12, textAlign: 'center', color: c.accent }, children: state.loading ? uiText("Loading…") : uiText("More chats") }) }) : null, renderItem: ({ item: row }) => {
116
88
  if (row.kind === 'directory')
117
89
  return _jsx(MessagingDirectoryRow, { contact: row.entry, appearance: design, onPress: () => void openDirectory(row.entry) });
118
90
  const item = row.chat;
119
- const person = item.contactId ? contacts[item.contactId] : undefined, title = item.contactId === userId ? uiText('Notes to self') : item.kind === 'group' ? item.name ?? 'Group' : person?.name ?? item.contactId ?? 'Chat';
91
+ const person = isSelf(item) ? { name: 'Me', avatarUrl: selfAvatarUrl ?? contacts[userId]?.avatarUrl } : item.contactId ? contacts[item.contactId] : undefined, title = item.contactId === userId ? uiText('Me') : item.kind === 'group' ? item.name ?? 'Group' : person?.name ?? item.contactId ?? 'Chat';
120
92
  const date = item.lastMessage ? new Date(item.lastMessage.createdAt) : null;
121
93
  return _jsxs(Pressable, { ref: node => { if (node)
122
94
  rows.current.set(item.id, node);
123
95
  else
124
96
  rows.current.delete(item.id); }, accessibilityRole: "button", accessibilityState: { selected: item.id === selectedId }, accessibilityLabel: item.unreadCount ? uiText('{name}, {count} unread', { name: title, count: uiNumber(item.unreadCount) }) : title, onPress: () => onSelect(item), onLongPress: () => openOptions(item), accessibilityActions: state.inboxActionsAvailable ? [{ name: 'showOptions', label: uiText("Chat options") }] : [], onAccessibilityAction: e => { if (e.nativeEvent.actionName === 'showOptions')
125
- openOptions(item); }, ...(Platform.OS === 'web' ? { onContextMenu: (e) => { e.preventDefault(); openOptions(item); } } : {}), style: { flexDirection: 'row', alignItems: 'center', gap: 12, paddingHorizontal: 12, paddingVertical: rowPadding, minHeight: Math.max(44, avatar.height + rowPadding * 2), backgroundColor: item.id === selectedId ? c.accent + '15' : undefined }, children: [friends?.showAvatars !== false && (person?.avatarUrl ? _jsx(Image, { source: { uri: person.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: title.slice(0, 1).toUpperCase() }) })), _jsxs(View, { style: { flex: 1, minWidth: 0 }, children: [_jsxs(Text, { numberOfLines: 1, style: { color: c.foreground, fontSize: friends?.nameSize ?? 16, fontWeight: '700' }, children: [title, item.muted ? uiText(" · Muted") : ''] }), friends?.showPreview !== false && _jsx(Text, { numberOfLines: friends?.previewLines ?? 1, style: { color: c.secondary, marginTop: 3, fontSize: friends?.previewSize ?? 14 }, children: preview(item) })] }), _jsxs(View, { style: { alignItems: 'flex-end', gap: 4 }, children: [friends?.showTime !== false && _jsx(Text, { style: { color: item.unreadCount ? c.accent : c.secondary, fontSize: 12 }, children: date ? date.toDateString() === new Date().toDateString() ? date.toLocaleTimeString(uiLocale, { hour: 'numeric', minute: '2-digit' }) : date.toLocaleDateString(uiLocale, { month: 'short', day: 'numeric' }) : '' }), friends?.showUnread !== false && item.unreadCount > 0 && _jsx(View, { style: { minWidth: friends?.unreadStyle === 'dot' ? 10 : 20, height: friends?.unreadStyle === 'dot' ? 10 : 20, borderRadius: 10, borderWidth: 1.5, borderColor: c.accent, backgroundColor: friends?.unreadStyle === 'filled' || friends?.unreadStyle === 'dot' ? c.accent : undefined, alignItems: 'center', justifyContent: 'center', paddingHorizontal: friends?.unreadStyle === 'dot' ? 0 : 5 }, children: friends?.unreadStyle !== 'dot' && _jsx(Text, { style: { color: friends?.unreadStyle === 'filled' ? messagingContrastInk(c.accent) : c.accent, fontSize: 10, fontWeight: '900' }, children: item.unreadCount > 99 ? '99+' : item.unreadCount }) })] })] });
126
- } }), directorySelection && _jsxs(MessagingPopup, { screen: "profile", compact: true, title: directorySelection.name, background: c.background, foreground: c.foreground, onClose: cancelDirectory, children: [_jsx(Text, { accessibilityRole: directoryError ? 'alert' : undefined, style: { color: messagingPopupColors.foreground, fontSize: 16, lineHeight: 23, paddingVertical: 12 }, children: directoryBusy ? uiText('Opening chat…') : directoryError || directorySelection.detail }), !!directoryError && directorySelection.available && _jsx(Pressable, { accessibilityRole: "button", onPress: () => void openDirectory(directorySelection), style: { minHeight: 44, justifyContent: 'center' }, children: _jsx(Text, { style: { color: c.accent }, children: uiText('Try again') }) })] }), selected && _jsxs(_Fragment, { children: [_jsx(MessagingMenuSurface, { visible: menuVisible, onDismiss: dismissed, onClose: () => { if (!busy)
97
+ openOptions(item); }, ...(Platform.OS === 'web' ? { onContextMenu: (e) => { e.preventDefault(); openOptions(item); } } : {}), style: { flexDirection: 'row', alignItems: 'center', gap: 12, paddingHorizontal: 16, paddingVertical: rowPadding, minHeight: Math.max(44, avatar.height + rowPadding * 2), backgroundColor: item.id === selectedId ? c.accent + '15' : undefined }, children: [friends?.showAvatars !== false && (person?.avatarUrl ? _jsx(Image, { source: { uri: person.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: title.slice(0, 1).toUpperCase() }) })), _jsxs(View, { style: { flex: 1, minWidth: 0, flexDirection: 'row', alignItems: 'flex-start', gap: 8 }, children: [_jsxs(View, { style: { flex: 1, minWidth: 0 }, children: [_jsx(Text, { numberOfLines: 1, style: { color: c.foreground, fontSize: friends?.nameSize ?? 16, fontWeight: '700' }, children: title }), friends?.showPreview !== false && _jsx(Text, { numberOfLines: friends?.previewLines ?? 1, style: { color: c.secondary, marginTop: 3, fontSize: friends?.previewSize ?? 14 }, children: preview(item) })] }), _jsxs(View, { testID: "messaging-inbox-row-meta", style: { flexShrink: 0, minWidth: 48, alignItems: 'flex-end', gap: 4, paddingTop: 1 }, children: [_jsxs(View, { style: { flexDirection: 'row', alignItems: 'center', justifyContent: 'flex-end', gap: 4 }, children: [item.muted && _jsx(MessageIcon, { name: "notifications-off-outline", size: 13, color: c.secondary }), friends?.showTime !== false && _jsx(Text, { style: { color: item.unreadCount ? c.accent : c.secondary, fontSize: 12 }, children: date ? date.toLocaleTimeString(uiLocale, { hour: 'numeric', minute: '2-digit' }) : '' })] }), friends?.showUnread !== false && item.unreadCount > 0 && _jsx(View, { style: { minWidth: friends?.unreadStyle === 'dot' ? 10 : 20, height: friends?.unreadStyle === 'dot' ? 10 : 20, borderRadius: 10, borderWidth: 1.5, borderColor: c.accent, backgroundColor: friends?.unreadStyle === 'filled' || friends?.unreadStyle === 'dot' ? c.accent : undefined, alignItems: 'center', justifyContent: 'center', paddingHorizontal: friends?.unreadStyle === 'dot' ? 0 : 5 }, children: friends?.unreadStyle !== 'dot' && _jsx(Text, { style: { color: friends?.unreadStyle === 'filled' ? messagingContrastInk(c.accent) : c.accent, fontSize: 10, fontWeight: '900' }, children: item.unreadCount > 99 ? '99+' : item.unreadCount }) })] })] })] });
98
+ } }), onNewConversation && design.menus?.friends?.items?.newChat !== false && _jsxs(Pressable, { testID: "messaging-new-message", accessibilityRole: "button", accessibilityLabel: uiText('New message'), onPress: onNewConversation, style: { position: 'absolute', end: 16, bottom: 32, minWidth: 124, height: 52, paddingHorizontal: 18, flexDirection: 'row', gap: 9, borderRadius: 26, backgroundColor: c.accent, alignItems: 'center', justifyContent: 'center', boxShadow: '0 8px 12px #0005', elevation: 8 }, children: [_jsx(MessageIcon, { name: "chat", size: 24, color: messagingContrastInk(c.accent) }), _jsx(Text, { style: { color: messagingContrastInk(c.accent), fontSize: 16, fontWeight: '600' }, children: uiText('Message') })] }), selected && _jsxs(_Fragment, { children: [_jsx(MessagingMenuSurface, { visible: menuVisible, onDismiss: dismissed, onClose: () => { if (!busy)
127
99
  setSelected(null); }, children: rect => {
128
100
  const palette = messagingMenuColors(design, 'friends'), menuLayout = messagingMenuLayout(design.menus?.friends);
129
101
  const width = Math.min(218, rect.width - 24), top = Math.max(12, Math.min(anchor.y - rect.top, rect.height - 124));
package/dist/index.d.ts CHANGED
@@ -1,3 +1,6 @@
1
+ export { messagingHeaderColors } from './header-colors.js';
2
+ export { MessagingReviewInbox } from './reviews.js';
3
+ export type { MessagingReviewInboxProps } from './reviews.js';
1
4
  import { type ConversationActions } from './chat-options.js';
2
5
  export type { ConversationActions } from './chat-options.js';
3
6
  import { type MessagingHeaderOptions } from './conversation-selector.js';
@@ -126,6 +129,8 @@ export interface MessagingScreenProps {
126
129
  language?: string;
127
130
  }>;
128
131
  appearance?: MessagingAppearance;
132
+ /** Appearance already loaded by the inbox, used until conversation settings arrive. */
133
+ initialAppearance?: MessagingAppearance;
129
134
  components?: MessagingComponents;
130
135
  style?: StyleProp<ViewStyle>;
131
136
  /** Set false when this conversation is covered by another route. */
@@ -195,10 +200,6 @@ export declare function GroupDiscussion({ threadRoot, onClose }: {
195
200
  threadRoot?: string;
196
201
  onClose: () => void;
197
202
  }): React.JSX.Element;
198
- export declare function messagingHeaderColors(design: MessagingAppearance, group: boolean): {
199
- background: string;
200
- foreground: string;
201
- };
202
203
  export declare function MessagingHeader({ children }?: {
203
204
  children?: ReactNode;
204
205
  }): React.JSX.Element;
@@ -216,7 +217,8 @@ export declare function MessageDeletion({ messages, onClose }: {
216
217
  export declare function MessagingList(): React.JSX.Element;
217
218
  export declare function MessagingComposer(): React.JSX.Element;
218
219
  /** Account navigation. Mount in the inbox/app toolbar, never in a contact menu. */
219
- export declare function MessagingAccountMenu({ onNewConversation, onNewGroup, onMaps, onPublicRooms }?: {
220
+ export declare function MessagingAccountMenu({ inbox, onNewConversation, onNewGroup, onMaps, onPublicRooms }?: {
221
+ inbox?: import('@robono/messaging').MessagingInboxClient;
220
222
  onNewConversation?: () => void;
221
223
  onNewGroup?: () => void;
222
224
  onMaps?: () => void;
@@ -229,3 +231,4 @@ export { MessagingInbox, type MessagingInboxProps } from './inbox.js';
229
231
  export type { PlaybackProps } from './media-ui.js';
230
232
  export type { InboxViewMemory } from './inbox-view.js';
231
233
  export type { MessagingDirectoryContact, MessagingDirectoryOptions } from './contact-directory.js';
234
+ export { MessagingBackupScreen } from './backup.js';