@robono/messaging-react-native 0.24.0 → 0.25.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 (108) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +75 -1
  3. package/RobonoMessagingRuntime.podspec +2 -0
  4. package/SBOM.spdx.json +1829 -557
  5. package/android/build.gradle +4 -1
  6. package/android/src/main/java/com/robono/messaging/RobonoBackupGoogle.java +76 -0
  7. package/android/src/main/java/com/robono/messaging/RobonoHistoryStore.java +173 -0
  8. package/android/src/main/java/com/robono/messaging/RobonoMessagingPackage.java +1 -1
  9. package/app.plugin.cjs +14 -1
  10. package/cloudkit/backup-schema.ckdb +13 -0
  11. package/dist/account-pages.d.ts +51 -0
  12. package/dist/account-pages.js +65 -0
  13. package/dist/account.d.ts +2 -1
  14. package/dist/account.js +6 -2
  15. package/dist/backup-background.d.ts +25 -0
  16. package/dist/backup-background.js +71 -0
  17. package/dist/backup-base64.d.ts +3 -0
  18. package/dist/backup-base64.js +41 -0
  19. package/dist/backup-google-authorization.d.ts +23 -0
  20. package/dist/backup-google-authorization.js +95 -0
  21. package/dist/backup.js +61 -16
  22. package/dist/bubble-design.d.ts +1 -1
  23. package/dist/cloudkit-backup.d.ts +14 -0
  24. package/dist/cloudkit-backup.js +193 -0
  25. package/dist/conversation-details.js +1 -1
  26. package/dist/customization.d.ts +1 -0
  27. package/dist/delivery-bar.d.ts +1 -1
  28. package/dist/delivery-bar.js +5 -2
  29. package/dist/delivery-notice.d.ts +9 -0
  30. package/dist/delivery-notice.js +15 -0
  31. package/dist/expo-backup-background.d.ts +17 -0
  32. package/dist/expo-backup-background.js +57 -0
  33. package/dist/expo-backup-cloudkit.d.ts +6 -0
  34. package/dist/expo-backup-cloudkit.js +11 -0
  35. package/dist/expo-backup-google.d.ts +7 -0
  36. package/dist/expo-backup-google.js +16 -0
  37. package/dist/expo-backup-network.d.ts +8 -0
  38. package/dist/expo-backup-network.js +18 -0
  39. package/dist/expo-backup-passkeys.d.ts +7 -0
  40. package/dist/expo-backup-passkeys.js +31 -7
  41. package/dist/expo-backup-settings.js +26 -8
  42. package/dist/expo-backup.d.ts +14 -0
  43. package/dist/expo-backup.js +22 -0
  44. package/dist/expo-bridge.d.ts +2 -0
  45. package/dist/expo-bridge.js +3 -1
  46. package/dist/expo-cache.js +20 -1
  47. package/dist/expo-device-history.d.ts +24 -0
  48. package/dist/expo-device-history.js +88 -0
  49. package/dist/expo-durable-history.d.ts +26 -0
  50. package/dist/expo-durable-history.js +56 -0
  51. package/dist/expo-history-backup.d.ts +3 -0
  52. package/dist/expo-history-backup.js +79 -0
  53. package/dist/expo-history-maintenance.d.ts +4 -0
  54. package/dist/expo-history-maintenance.js +23 -0
  55. package/dist/expo-history-previews.d.ts +5 -0
  56. package/dist/expo-history-previews.js +57 -0
  57. package/dist/expo-history.d.ts +1 -1
  58. package/dist/expo-history.js +2 -2
  59. package/dist/expo-media.d.ts +2 -0
  60. package/dist/expo-media.js +15 -21
  61. package/dist/expo-messenger.d.ts +8 -0
  62. package/dist/expo-messenger.js +18 -7
  63. package/dist/expo-notifications.d.ts +17 -1
  64. package/dist/expo-notifications.js +36 -16
  65. package/dist/expo-outbox.d.ts +2 -0
  66. package/dist/expo-outbox.js +1 -1
  67. package/dist/expo-oversight.d.ts +15 -0
  68. package/dist/expo-oversight.js +15 -0
  69. package/dist/expo-reviews.d.ts +4 -1
  70. package/dist/expo-reviews.js +122 -17
  71. package/dist/expo-screen.js +5 -4
  72. package/dist/expo-thumbnails.d.ts +2 -2
  73. package/dist/expo-thumbnails.js +48 -5
  74. package/dist/expo.d.ts +10 -0
  75. package/dist/expo.js +8 -0
  76. package/dist/header-calls.js +1 -1
  77. package/dist/inbox-search.d.ts +1 -1
  78. package/dist/inbox-search.js +7 -3
  79. package/dist/inbox.d.ts +1 -0
  80. package/dist/inbox.js +5 -5
  81. package/dist/index.d.ts +8 -3
  82. package/dist/index.js +138 -63
  83. package/dist/linked-apps.d.ts +45 -0
  84. package/dist/linked-apps.js +40 -0
  85. package/dist/loading-messages.d.ts +1 -1
  86. package/dist/loading-messages.js +1 -1
  87. package/dist/media-controller.d.ts +2 -0
  88. package/dist/native-history-authorization.d.ts +4 -0
  89. package/dist/native-history-authorization.js +69 -0
  90. package/dist/native-history-backup.d.ts +16 -0
  91. package/dist/native-history-backup.js +144 -0
  92. package/dist/native-history.d.ts +14 -0
  93. package/dist/native-history.js +186 -0
  94. package/dist/native-outbox.d.ts +2 -0
  95. package/dist/oversight-session.d.ts +4 -0
  96. package/dist/oversight-session.js +14 -0
  97. package/dist/preview-layout.d.ts +12 -0
  98. package/dist/preview-layout.js +102 -0
  99. package/dist/recent-media.js +2 -1
  100. package/dist/reviews.d.ts +8 -4
  101. package/dist/reviews.js +53 -26
  102. package/dist/scheduled.js +2 -2
  103. package/dist/search.js +18 -8
  104. package/ios/RobonoBackupCloudKit.m +96 -0
  105. package/ios/RobonoHistoryStore.m +170 -0
  106. package/package.json +22 -4
  107. package/plugin/backup-expiration.cjs +23 -0
  108. package/plugin/prepare-native.cjs +12 -0
@@ -0,0 +1,15 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useMemo } from 'react';
3
+ import { createMessagingOversightMediaRequest } from '@robono/messaging';
4
+ import { useMessagingOversightSession } from './oversight-session.js';
5
+ import { ExpoMessagingScreen } from './expo-screen.js';
6
+ import { createExpoMessagingStorage } from './expo-media.js';
7
+ /** Uses the shared image/video/document/voice viewers. Reviewer activity never
8
+ * calls the subject's read, consumed, presence or message-mutation endpoints. */
9
+ export function ExpoMessagingOversight({ endpoint, request, reviewerId, subjectId, conversationId, audioSession, mediaViewer, ...screen }) {
10
+ const client = useMessagingOversightSession(request, reviewerId, subjectId, conversationId);
11
+ const storage = useMemo(() => createExpoMessagingStorage({ url: endpoint, getAccessToken: async () => { throw Error('Use the authorized oversight request.'); }, request: createMessagingOversightMediaRequest({ request, subjectId }) }), [endpoint, request, subjectId]);
12
+ if (!client)
13
+ return null;
14
+ return _jsx(ExpoMessagingScreen, { ...screen, client: client, userId: subjectId, storage: storage, audioSession: audioSession, mediaViewer: { download: !!screen.onDownloadAttachment, share: false, open: false, ...mediaViewer, forward: false, delete: false }, preloadRecentMedia: false, languageTools: { translation: false, transcription: false, voiceOutput: false } });
15
+ }
@@ -1,3 +1,6 @@
1
1
  import React from "react";
2
+ import { type MessagingAudioSession } from './expo-media.js';
2
3
  import { type MessagingReviewInboxProps } from "./reviews.js";
3
- export declare function ExpoMessageReviewInbox(props: Omit<MessagingReviewInboxProps, "renderMedia">): React.JSX.Element;
4
+ export declare function ExpoMessageReviewInbox({ audioSession, ...props }: Omit<MessagingReviewInboxProps, "renderMedia"> & {
5
+ audioSession?: MessagingAudioSession;
6
+ }): React.JSX.Element;
@@ -1,15 +1,27 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { useEffect } from "react";
3
- import { Pressable, Text, View } from "react-native";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useMemo, useRef, useState } from "react";
3
+ import { createExpoMessagingAudioSession } from './expo-media.js';
4
+ import { ActivityIndicator, Pressable, Text, View } from "react-native";
4
5
  import { useAudioPlayer, useAudioPlayerStatus } from "expo-audio";
5
6
  import { useVideoPlayer } from "expo-video";
6
7
  import { MessengerVideoView } from "./messenger-video-view.js";
8
+ import { ExpoDocumentPreview } from './expo-document.js';
9
+ import { withMessagingDeadline } from '@robono/messaging';
10
+ import * as FS from 'expo-file-system/legacy';
11
+ import { randomUUID } from 'expo-crypto';
7
12
  import { MessagingReviewInbox, } from "./reviews.js";
8
- function ReviewVoice({ url }) {
13
+ function ReviewVoice({ url, audio, foreground }) {
9
14
  const player = useAudioPlayer({ uri: url }), status = useAudioPlayerStatus(player);
15
+ const release = useRef(null), generation = useRef(0), starting = useRef(false);
16
+ const releasing = useRef(Promise.resolve());
17
+ const [error, setError] = useState('');
18
+ const releaseAudio = () => { const done = release.current; release.current = null; if (done)
19
+ releasing.current = releasing.current.then(done).catch(() => { }); };
20
+ const stop = () => { generation.current++; player.pause(); releaseAudio(); };
21
+ useEffect(() => () => { generation.current++; releaseAudio(); }, [player, audio]);
10
22
  useEffect(() => {
11
23
  if (status.didJustFinish) {
12
- player.pause();
24
+ stop();
13
25
  void player.seekTo(0);
14
26
  }
15
27
  }, [player, status.didJustFinish]);
@@ -18,23 +30,116 @@ function ReviewVoice({ url }) {
18
30
  : status.playing
19
31
  ? "Pause recording"
20
32
  : "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 }) }) }));
33
+ return (_jsxs(View, { children: [_jsxs(Pressable, { accessibilityRole: "button", accessibilityLabel: label, disabled: !status.isLoaded, onPress: async () => {
34
+ if (status.playing) {
35
+ stop();
36
+ return;
37
+ }
38
+ if (starting.current)
39
+ return;
40
+ starting.current = true;
41
+ setError('');
42
+ const current = generation.current;
43
+ let done;
44
+ try {
45
+ await releasing.current;
46
+ if (current !== generation.current)
47
+ return;
48
+ done = await audio.acquire('playback');
49
+ if (current !== generation.current) {
50
+ await done();
51
+ return;
52
+ }
53
+ release.current = done;
54
+ player.play();
55
+ }
56
+ catch {
57
+ if (current === generation.current) {
58
+ release.current = null;
59
+ setError('This recording could not be played. Try again.');
60
+ }
61
+ await done?.().catch(() => { });
62
+ }
63
+ finally {
64
+ starting.current = false;
65
+ }
66
+ }, style: { padding: 14, minHeight: 48, justifyContent: "center", alignItems: "center" }, children: [_jsx(Text, { style: { color: foreground, opacity: status.isLoaded ? 1 : 0 }, children: status.playing ? "Pause recording" : "Play recording" }), !status.isLoaded && _jsx(View, { pointerEvents: "none", style: { position: "absolute", inset: 0, alignItems: "center", justifyContent: "center" }, children: _jsx(ActivityIndicator, { color: foreground }) })] }), !!error && _jsx(Text, { accessibilityRole: "alert", style: { color: foreground }, children: error })] }));
27
67
  }
28
- function ReviewVideo({ url }) {
68
+ function ReviewVideo({ url, audio, foreground }) {
29
69
  const player = useVideoPlayer(url, (p) => {
30
70
  p.loop = false;
31
71
  });
72
+ const [ready, setReady] = useState(false), [error, setError] = useState('');
73
+ useEffect(() => {
74
+ let active = true, release;
75
+ setReady(false);
76
+ setError('');
77
+ void audio.acquire('playback').then(async (done) => { if (!active) {
78
+ await done();
79
+ return;
80
+ } release = done; setReady(true); }).catch(() => { if (active)
81
+ setError('This video could not be played. Reopen the attachment to try again.'); });
82
+ return () => { active = false; void release?.().catch(() => { }); };
83
+ }, [audio, player]);
84
+ if (!ready)
85
+ return _jsx(View, { style: { width: "100%", height: 240, alignItems: "center", justifyContent: "center" }, children: error ? _jsx(Text, { accessibilityRole: "alert", style: { color: foreground }, children: error }) : _jsx(ActivityIndicator, { accessibilityLabel: "Preparing video", color: foreground }) });
32
86
  return (_jsx(MessengerVideoView, { player: player, nativeControls: true, style: { width: "100%", height: 240 } }));
33
87
  }
34
- export function ExpoMessageReviewInbox(props) {
35
- return (_jsx(MessagingReviewInbox, { ...props, renderMedia: ({ url, kind }) => kind === "voice"
36
- ? _jsx(ReviewVoice, { url: url })
88
+ function ReviewDocument({ url, file, foreground }) {
89
+ const [uri, setUri] = useState(null), [error, setError] = useState('');
90
+ useEffect(() => {
91
+ const controller = new AbortController();
92
+ let transfer, local;
93
+ setUri(null);
94
+ setError('');
95
+ const cleanup = async () => { if (local)
96
+ await FS.deleteAsync(local, { idempotent: true }).catch(() => { }); };
97
+ void withMessagingDeadline(async (signal) => {
98
+ const pdf = file.mimeType === 'application/pdf', text = /^(text\/(plain|csv)|application\/json)$/i.test(file.mimeType);
99
+ if ((!pdf && !text) || !Number.isSafeInteger(file.byteSize) || file.byteSize < 1 || file.byteSize > (pdf ? 25 : 1) * 1024 * 1024)
100
+ throw Error('preview_unavailable');
101
+ const source = new URL(url), localDevelopment = typeof __DEV__ !== 'undefined' && __DEV__ && source.protocol === 'http:' && /^(localhost|127\.0\.0\.1|10\.\d+\.\d+\.\d+|192\.168\.\d+\.\d+|172\.(1[6-9]|2\d|3[01])\.\d+\.\d+)$/.test(source.hostname);
102
+ if (source.protocol !== 'https:' && !localDevelopment || source.username || source.password || !FS.cacheDirectory)
103
+ throw Error('preview_unavailable');
104
+ const directory = FS.cacheDirectory + 'robono-private-review/';
105
+ await FS.makeDirectoryAsync(directory, { intermediates: true });
106
+ if (signal.aborted)
107
+ throw Error('cancelled');
108
+ local = directory + randomUUID();
109
+ transfer = FS.createDownloadResumable(url, local, {}, progress => { if (progress.totalBytesWritten > file.byteSize)
110
+ void transfer?.cancelAsync().catch(() => { }); });
111
+ const cancel = () => { void transfer?.cancelAsync().catch(() => { }); };
112
+ signal.addEventListener('abort', cancel, { once: true });
113
+ try {
114
+ if (signal.aborted)
115
+ throw Error('cancelled');
116
+ const result = await transfer.downloadAsync();
117
+ if (signal.aborted || result?.status !== 200)
118
+ throw Error('preview_unavailable');
119
+ const info = await FS.getInfoAsync(local);
120
+ if (!info.exists || info.isDirectory || info.size !== file.byteSize)
121
+ throw Error('preview_unavailable');
122
+ if (!controller.signal.aborted)
123
+ setUri(local);
124
+ }
125
+ finally {
126
+ signal.removeEventListener('abort', cancel);
127
+ if (signal.aborted)
128
+ await cleanup();
129
+ }
130
+ }, { signal: controller.signal, timeoutMs: 60000 }).catch(async () => { await cleanup(); if (!controller.signal.aborted)
131
+ setError('This document could not be previewed. Reopen the attachment to try again.'); });
132
+ return () => { controller.abort(); void cleanup(); };
133
+ }, [url, file.mimeType, file.byteSize]);
134
+ return uri ? _jsx(View, { style: { height: 320, backgroundColor: '#111' }, children: _jsx(ExpoDocumentPreview, { file: { ...file, uri } }) }) : _jsx(View, { style: { height: 320, alignItems: "center", justifyContent: "center" }, children: error ? _jsx(Text, { style: { color: foreground }, accessibilityRole: "alert", children: error }) : _jsx(ActivityIndicator, { accessibilityLabel: "Opening document", color: foreground }) });
135
+ }
136
+ export function ExpoMessageReviewInbox({ audioSession, ...props }) {
137
+ const audio = useMemo(() => audioSession ?? createExpoMessagingAudioSession(), [audioSession]);
138
+ return (_jsx(MessagingReviewInbox, { ...props, renderMedia: ({ url, kind, foreground, file }) => kind === "voice"
139
+ ? _jsx(ReviewVoice, { url: url, audio: audio, foreground: foreground })
37
140
  : kind === "video"
38
- ? _jsx(ReviewVideo, { url: url })
39
- : _jsx(Text, { children: "This file type needs a host-provided private viewer." }) }));
141
+ ? _jsx(ReviewVideo, { url: url, audio: audio, foreground: foreground })
142
+ : kind === "document" && file
143
+ ? _jsx(ReviewDocument, { url: url, file: file, foreground: foreground })
144
+ : _jsx(Text, { style: { color: foreground }, children: "This file type needs a host-provided private viewer." }) }));
40
145
  }
@@ -1,5 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { usePlaybackReporting } from './playback-reporting.js';
3
+ import { withMessagingDeadline } from '@robono/messaging';
3
4
  import { Linking } from 'react-native';
4
5
  import { isRemoteMessagingAsset } from './media-access.js';
5
6
  import { ExpoDocumentPreview } from './expo-document.js';
@@ -16,7 +17,7 @@ import { expoOutbox } from './expo-outbox.js';
16
17
  import { expoSaved } from './expo-saved.js';
17
18
  export { createExpoMessagingClient } from './expo-outbox.js';
18
19
  import { createExpoThumbnails } from './expo-thumbnails.js';
19
- import { useCallback, useEffect, useContext, useMemo, useRef, useState, useSyncExternalStore } from 'react';
20
+ import { useCallback, useEffect, useLayoutEffect, useContext, useMemo, useRef, useState, useSyncExternalStore } from 'react';
20
21
  import { AppState, Image, Modal, Platform, Pressable, ScrollView, View } from 'react-native';
21
22
  import { SafeAreaProvider, SafeAreaView } from 'react-native-safe-area-context';
22
23
  import MaterialIcons from "./visual/RobonoIcon";
@@ -488,7 +489,7 @@ function ExpoMessagingScreenContent({ storage, audioSession, renderConversation,
488
489
  controller.restorePrepared(media.assetId, copy, kind);
489
490
  return copy;
490
491
  }, [controller, recorder, props.client, outbox, audioSession]);
491
- const thumbnails = useMemo(() => createExpoThumbnails(recent.storage, id => controller.getPrepared(id) ?? recorder.getPrepared(id), createExpoMessagingDevice(audioSession).remove), [recent, controller, recorder, audioSession]);
492
+ const thumbnails = useMemo(() => createExpoThumbnails(recent.storage, id => controller.getPrepared(id) ?? recorder.getPrepared(id), createExpoMessagingDevice(audioSession).remove, props.client), [recent, controller, recorder, audioSession, props.client]);
492
493
  const prepare = async (kind, media) => {
493
494
  await restore(media, kind);
494
495
  const owner = recorder.getPrepared(media.assetId) ? recorder : controller;
@@ -508,7 +509,7 @@ function ExpoMessagingScreenContent({ storage, audioSession, renderConversation,
508
509
  useEffect(() => { const sub = AppState.addEventListener('change', value => { if (value !== 'active')
509
510
  thumbnails.clear(); }); return () => sub.remove(); }, [thumbnails]);
510
511
  const cacheDisposal = useRef(new Map());
511
- useEffect(() => {
512
+ useLayoutEffect(() => {
512
513
  clearTimeout(cacheDisposal.current.get(recent));
513
514
  cacheDisposal.current.delete(recent);
514
515
  const sync = () => { const snapshot = props.client.getSnapshot(); if (preloadRecentMedia && current.current.active !== false && snapshot.settings?.enabled && !snapshot.error && AppState.currentState === 'active')
@@ -585,7 +586,7 @@ function ExpoMessagingScreenContent({ storage, audioSession, renderConversation,
585
586
  }, []);
586
587
  return ready ? _jsx(ExpoSocialPlayer, { ...ui }) : null;
587
588
  }, [audioSession]);
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]);
589
+ useEffect(() => saved?.bindDownload(async (m) => { const device = createExpoMessagingDevice(audioSession), file = await withMessagingDeadline(signal => storage.download(m, { signal, onProgress: () => { } }), { timeoutMs: 120000 }); return { file, release: () => device.remove(file) }; }), [saved, storage, audioSession]);
589
590
  const attachmentPreview = useMemo(() => Object.assign(async (m, options) => { if (m.media && m.kind !== 'text' && m.kind !== 'poll')
590
591
  await restore(m.media, m.kind); return thumbnails.preview(m, options); }, { peek: thumbnails.peek }), [restore, thumbnails]);
591
592
  const defaultQuoteReady = useCallback(() => { if (Platform.OS === 'android')
@@ -1,8 +1,8 @@
1
- import type { MessagingMessage } from '@robono/messaging';
1
+ import type { MessagingMessage, MessagingClient } from '@robono/messaging';
2
2
  import type { LocalMessagingMedia, MessagingMediaStorage } from './media-controller.js';
3
3
  /** Small local previews, with bounded downloads and memory. Large originals stay
4
4
  * tap-to-open until the storage service supplies a dedicated thumbnail. */
5
- export declare function createExpoThumbnails(storage: MessagingMediaStorage, local: (id: string) => LocalMessagingMedia | undefined, remove: (file: LocalMessagingMedia) => Promise<void>): {
5
+ export declare function createExpoThumbnails(storage: MessagingMediaStorage, local: (id: string) => LocalMessagingMedia | undefined, remove: (file: LocalMessagingMedia) => Promise<void>, history?: Pick<MessagingClient, 'cachedHistoryPreview' | 'cacheHistoryPreview' | 'canCacheHistoryPreview'>): {
6
6
  preview: (message: MessagingMessage, options?: {
7
7
  refresh?: boolean;
8
8
  }) => Promise<{}>;
@@ -3,11 +3,13 @@ import { MessagingPreviewCache } from './preview-cache.js';
3
3
  import * as ImageManipulator from 'expo-image-manipulator';
4
4
  import * as VideoThumbnails from 'expo-video-thumbnails';
5
5
  import * as FS from 'expo-file-system/legacy';
6
+ import { Image } from 'react-native';
6
7
  /** Small local previews, with bounded downloads and memory. Large originals stay
7
8
  * tap-to-open until the storage service supplies a dedicated thumbnail. */
8
- export function createExpoThumbnails(storage, local, remove) {
9
+ export function createExpoThumbnails(storage, local, remove, history) {
9
10
  const cache = new MessagingPreviewCache();
10
- const clear = () => cache.clear();
11
+ const saving = new MessagingPreviewCache({ concurrency: 1, maximum: 8, ttlMs: 60000, timeoutMs: 3000 });
12
+ const clear = () => { cache.clear(); saving.clear(); };
11
13
  const keyFor = (message) => JSON.stringify([message.conversationId, message.media?.assetId, message.revision ?? 0, message.media]);
12
14
  function preview(message, options) {
13
15
  const media = message.media;
@@ -18,11 +20,18 @@ export function createExpoThumbnails(storage, local, remove) {
18
20
  if (!['image', 'video'].includes(message.kind))
19
21
  return Promise.resolve({});
20
22
  const id = media.assetId, key = keyFor(message);
21
- if (options?.refresh)
23
+ if (options?.refresh) {
22
24
  cache.invalidate(key);
25
+ saving.invalidate(key);
26
+ }
23
27
  return cache.get(key, async (signal) => {
24
28
  if (signal.aborted)
25
29
  return {};
30
+ const saved = options?.refresh ? undefined : await history?.cachedHistoryPreview?.(message).catch(() => undefined);
31
+ if (signal.aborted)
32
+ return {};
33
+ if (saved)
34
+ return { uri: saved };
26
35
  let file = local(id), downloaded = false, poster, thumbnail;
27
36
  // An optimistic bubble has no server message ID yet. Only its local file can
28
37
  // supply a preview until acknowledgement replaces the pending bubble.
@@ -31,20 +40,22 @@ export function createExpoThumbnails(storage, local, remove) {
31
40
  try {
32
41
  let dedicated = false;
33
42
  if (!file && storage.thumbnail && !useSmallOriginalPreview(message)) {
34
- file = await storage.thumbnail(message, { signal, onProgress: () => { } }) ?? undefined;
43
+ file = await storage.thumbnail(message, { signal, purpose: 'preview', onProgress: () => { } }) ?? undefined;
35
44
  dedicated = !!file;
36
45
  downloaded = !!file;
37
46
  }
38
47
  if (!file) {
39
48
  if (media.byteSize > 2 * 1024 * 1024)
40
49
  return {};
41
- file = await storage.download(message, { signal: signal, onProgress: () => { } });
50
+ file = await storage.download(message, { signal, purpose: 'preview', onProgress: () => { } });
42
51
  downloaded = true;
43
52
  }
44
53
  if (signal.aborted)
45
54
  return {};
46
55
  // A server thumbnail or small original JPEG is already bounded. Re-encoding adds
47
56
  // another native decode/encode before the first visible frame.
57
+ if (dedicated && file.uri.startsWith('data:image/jpeg;base64,') && file.uri.length <= 65558)
58
+ return signal.aborted ? {} : { uri: file.uri };
48
59
  if (dedicated || message.kind === 'image' && isSmallMessagingJpeg(file)) {
49
60
  const base64 = await FS.readAsStringAsync(file.uri, { encoding: FS.EncodingType.Base64 });
50
61
  return signal.aborted ? {} : { uri: 'data:image/jpeg;base64,' + base64 };
@@ -62,6 +73,38 @@ export function createExpoThumbnails(storage, local, remove) {
62
73
  if (uri && FS.cacheDirectory && uri.startsWith(FS.cacheDirectory))
63
74
  await FS.deleteAsync(uri, { idempotent: true }).catch(() => { });
64
75
  }
76
+ }).then(value => {
77
+ if (value.uri && history?.canCacheHistoryPreview?.(message))
78
+ void saving.get(key, async (signal) => {
79
+ let uri = value.uri, output;
80
+ try {
81
+ // Save a smaller copy without delaying the first visible preview. Detailed
82
+ // photos can exceed the disk budget even after the display-size resize.
83
+ if (uri.length > 65558) {
84
+ const dimensions = await new Promise((resolve, reject) => Image.getSize(uri, (width, height) => resolve({ width, height }), reject));
85
+ for (const maximum of [320, 160]) {
86
+ if (signal.aborted)
87
+ return {};
88
+ const scale = Math.min(1, maximum / Math.max(dimensions.width, dimensions.height));
89
+ const image = await ImageManipulator.manipulateAsync(value.uri, [{ resize: { width: Math.max(1, Math.round(dimensions.width * scale)), height: Math.max(1, Math.round(dimensions.height * scale)) } }], { compress: .6, format: ImageManipulator.SaveFormat.JPEG, base64: true });
90
+ output = image.uri;
91
+ uri = 'data:image/jpeg;base64,' + (image.base64 ?? '');
92
+ await FS.deleteAsync(output, { idempotent: true });
93
+ output = undefined;
94
+ if (image.base64 && uri.length <= 65558)
95
+ break;
96
+ }
97
+ }
98
+ if (!signal.aborted)
99
+ await history.cacheHistoryPreview(message, uri);
100
+ return { uri };
101
+ }
102
+ finally {
103
+ if (output && FS.cacheDirectory && output.startsWith(FS.cacheDirectory))
104
+ await FS.deleteAsync(output, { idempotent: true }).catch(() => { });
105
+ }
106
+ });
107
+ return value;
65
108
  });
66
109
  }
67
110
  // Uploaded IDs get their own authorized preview; never alias access between assets.
package/dist/expo.d.ts CHANGED
@@ -8,4 +8,14 @@ export { configureExpoMessagingCache, maintainExpoMessagingCache, type Messaging
8
8
  export { ExpoMessageReviewInbox } from './expo-reviews.js';
9
9
  export { createExpoMessagingBackupCrypto } from './expo-backup-crypto.js';
10
10
  export { createExpoMessagingBackupSettings } from './expo-backup-settings.js';
11
+ export { createExpoMessagingBackup } from './expo-backup.js';
12
+ export { createExpoCloudKitMessagingBackup } from './expo-backup-cloudkit.js';
13
+ export { createExpoGoogleMessagingBackup } from './expo-backup-google.js';
11
14
  export { createExpoMessagingBackupPasskeys } from './expo-backup-passkeys.js';
15
+ export { createExpoDurableHistoryStore, createExpoDurableHistoryMedia, readExpoDurableHistoryOriginal } from './expo-durable-history.js';
16
+ export { createExpoDeviceHistory, withExpoDeviceHistoryStorage } from './expo-device-history.js';
17
+ export { createExpoDurableHistoryBackupSource } from './expo-history-backup.js';
18
+ export { ExpoMessagingOversight, type ExpoMessagingOversightProps } from './expo-oversight.js';
19
+ export { MessagingLinkedAppsScreen } from './linked-apps.js';
20
+ export type { MessagingLinkedApps, MessagingLinkedNetwork, MessagingLinkedContact } from './linked-apps.js';
21
+ export type { MessagingAccountPages, MessagingAccountPage } from './account-pages.js';
package/dist/expo.js CHANGED
@@ -7,4 +7,12 @@ export { configureExpoMessagingCache, maintainExpoMessagingCache } from './expo-
7
7
  export { ExpoMessageReviewInbox } from './expo-reviews.js';
8
8
  export { createExpoMessagingBackupCrypto } from './expo-backup-crypto.js';
9
9
  export { createExpoMessagingBackupSettings } from './expo-backup-settings.js';
10
+ export { createExpoMessagingBackup } from './expo-backup.js';
11
+ export { createExpoCloudKitMessagingBackup } from './expo-backup-cloudkit.js';
12
+ export { createExpoGoogleMessagingBackup } from './expo-backup-google.js';
10
13
  export { createExpoMessagingBackupPasskeys } from './expo-backup-passkeys.js';
14
+ export { createExpoDurableHistoryStore, createExpoDurableHistoryMedia, readExpoDurableHistoryOriginal } from './expo-durable-history.js';
15
+ export { createExpoDeviceHistory, withExpoDeviceHistoryStorage } from './expo-device-history.js';
16
+ export { createExpoDurableHistoryBackupSource } from './expo-history-backup.js';
17
+ export { ExpoMessagingOversight } from './expo-oversight.js';
18
+ export { MessagingLinkedAppsScreen } from './linked-apps.js';
@@ -41,7 +41,7 @@ export function MessagingHeaderCalls({ actions, name, group, color }) {
41
41
  } }; document.addEventListener('keydown', close, true); return () => document.removeEventListener('keydown', close, true); }, [visible]);
42
42
  useEffect(() => { pending.current = null; setVisible(false); setError(''); }, [name, group]);
43
43
  const choose = (kind) => { pending.current = kind; setVisible(false); };
44
- const button = (label, icon, press) => _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText(label), onPress: press, style: { width: icon === 'video' ? 42 : 44, height: icon === 'video' ? 42 : 44, alignItems: 'center', justifyContent: 'center' }, children: _jsx(MessageIcon, { name: icon, size: 23, color: color }) });
44
+ const button = (label, icon, press) => _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText(label), onPress: press, style: { width: 44, height: 44, alignItems: 'center', justifyContent: 'center' }, children: _jsx(MessageIcon, { name: icon, size: 23, color: color }) });
45
45
  const row = (kind, label, detail) => _jsxs(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText(label), onPress: () => choose(kind), style: ({ pressed }) => ({ flexDirection: 'row', alignItems: 'center', gap: 16, minHeight: 80, padding: 12, borderRadius: 18, backgroundColor: pressed ? c.incoming : 'transparent' }), children: [_jsx(View, { style: { width: 48, height: 48, borderRadius: 24, backgroundColor: c.incoming, alignItems: 'center', justifyContent: 'center' }, children: _jsx(MessageIcon, { name: kind === 'phone' ? 'phone-portrait-outline' : 'phone', color: c.foreground, size: 24 }) }), _jsxs(View, { style: { flex: 1, gap: 4 }, children: [_jsx(Text, { style: { color: c.foreground, fontSize: 18, fontWeight: '600' }, children: uiText(label) }), _jsx(Text, { style: { color: c.secondary, fontSize: 15 }, children: uiText(detail) })] })] });
46
46
  return _jsxs(_Fragment, { children: [actions?.video && button(actions.videoLabel ?? 'Video call', 'video', () => void invoke('video')), (actions?.voice || validPhone) && button(uiText('Call {name}', { name }), 'phone', () => { if (!validPhone) {
47
47
  void invoke('voice');
@@ -1,7 +1,7 @@
1
1
  import { type InboxViewMemory } from './inbox-view.js';
2
2
  import React from 'react';
3
3
  import type { ConversationSummary, MessagingInboxClient, MessagingAppearance } from '@robono/messaging';
4
- /** Main-screen search covers retained messages beyond the current inbox page. */
4
+ /** Main-screen search covers authorized server and device history beyond the loaded inbox. */
5
5
  export declare function InboxMessageSearch({ client, query, appearance, name, chats, onSelect, viewMemory, directoryHeader }: {
6
6
  directoryHeader?: React.ReactNode;
7
7
  viewMemory: InboxViewMemory;
@@ -5,7 +5,7 @@ import { messagingScreenAppearance } from '@robono/messaging';
5
5
  import { useRobonoLocale } from './localization.js';
6
6
  import { useEffect, useRef, useState } from 'react';
7
7
  import { ActivityIndicator, FlatList, Pressable, View } from 'react-native';
8
- /** Main-screen search covers retained messages beyond the current inbox page. */
8
+ /** Main-screen search covers authorized server and device history beyond the loaded inbox. */
9
9
  export function InboxMessageSearch({ client, query, appearance, name, chats, onSelect, viewMemory, directoryHeader }) {
10
10
  const { text: uiText, locale: uiLocale, number: uiNumber, count: uiCount } = useRobonoLocale();
11
11
  const c = messagingScreenAppearance(appearance, 'inboxSearch').colors, [rows, setRows] = useState([]), [next, setNext] = useState(null), [busy, setBusy] = useState(true), [error, setError] = useState('');
@@ -30,8 +30,12 @@ export function InboxMessageSearch({ client, query, appearance, name, chats, onS
30
30
  collected.set(row.message.conversationId + ':' + row.message.id, row);
31
31
  if (more || !page.hasMore || collected.size >= target)
32
32
  break;
33
- if (!page.nextCursor || seen.has(page.nextCursor) || seen.size > Math.ceil(target / 20) + 2)
33
+ if (!page.nextCursor || seen.has(page.nextCursor))
34
34
  throw Error(uiText('Messages could not be searched.'));
35
+ // Permission filtering can leave a valid empty page. Bound automatic work
36
+ // and keep More results available instead of reporting a search failure.
37
+ if (seen.size >= Math.ceil(target / 20) + 3)
38
+ break;
35
39
  seen.add(page.nextCursor);
36
40
  before = page.nextCursor;
37
41
  } while (true);
@@ -62,5 +66,5 @@ export function InboxMessageSearch({ client, query, appearance, name, chats, onS
62
66
  const timer = setTimeout(() => void search(), 300);
63
67
  return () => { clearTimeout(timer); ++generation.current; controller.current?.abort(); };
64
68
  }, [client, query]);
65
- return _jsx(MessagingTypography, { appearance: appearance, screen: "inboxSearch", children: _jsx(FlatList, { ...scroll, testID: "messaging-inbox-search-results", style: { flex: 1, backgroundColor: c.background }, data: rows, keyExtractor: row => row.message.conversationId + ':' + row.message.id, keyboardShouldPersistTaps: "handled", ListHeaderComponent: _jsxs(View, { children: [directoryHeader, chats.length > 0 && _jsxs(_Fragment, { children: [_jsx(Text, { style: { paddingHorizontal: 16, paddingVertical: 8, color: c.secondary, fontSize: 14, fontWeight: '600' }, children: uiText("Chats") }), chats.map(chat => _jsx(Pressable, { accessibilityRole: "button", onPress: () => onSelect(chat), style: { minHeight: 48, paddingHorizontal: 16, justifyContent: 'center' }, children: _jsx(Text, { style: { color: c.foreground, fontSize: 16 }, children: name(chat) }) }, chat.id))] }), _jsx(Text, { style: { paddingHorizontal: 16, paddingVertical: 12, color: c.secondary, fontSize: 14, fontWeight: '600' }, children: uiText("Messages") })] }), ListEmptyComponent: !busy && !error ? _jsx(Text, { style: { padding: 16, color: c.secondary }, children: uiText("No matching messages.") }) : null, renderItem: ({ item }) => _jsxs(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText("Message in {value1}: {value2}", { value1: name(item.conversation), value2: item.message.text ?? '' }), onPress: () => onSelect(item.conversation, item.message.id), style: { paddingHorizontal: 16, paddingVertical: 12, gap: 5, borderBottomWidth: 1, borderBottomColor: c.foreground + '16' }, children: [_jsxs(View, { style: { flexDirection: 'row', gap: 8 }, children: [_jsx(Text, { numberOfLines: 1, style: { flex: 1, fontSize: 16, fontWeight: '600', color: c.foreground }, children: name(item.conversation) }), _jsx(Text, { style: { fontSize: 12, color: c.secondary }, children: new Date(item.message.createdAt).toLocaleDateString(uiLocale) })] }), _jsx(Text, { numberOfLines: 3, style: { fontSize: 15, lineHeight: 21, color: c.secondary }, children: item.message.text })] }), ListFooterComponent: _jsxs(View, { children: [busy && _jsx(ActivityIndicator, { accessibilityLabel: uiText("Searching all messages"), color: c.accent, style: { padding: 16 } }), !!error && _jsxs(_Fragment, { children: [_jsx(Text, { accessibilityRole: "alert", style: { padding: 16, color: c.foreground }, children: error }), _jsx(Pressable, { accessibilityRole: "button", onPress: () => void search(rows.length > 0 && !!next), style: { minHeight: 44, paddingHorizontal: 16, justifyContent: 'center' }, children: _jsx(Text, { style: { color: c.accent }, children: uiText("Try again") }) })] }), next && !busy && !error && _jsx(Pressable, { accessibilityRole: "button", onPress: () => void search(true), style: { minHeight: 48, alignItems: 'center', justifyContent: 'center' }, children: _jsx(Text, { style: { color: c.accent }, children: uiText("More results") }) })] }) }) });
69
+ return _jsx(MessagingTypography, { appearance: appearance, screen: "inboxSearch", children: _jsx(FlatList, { ...scroll, testID: "messaging-inbox-search-results", style: { flex: 1, backgroundColor: c.background }, data: rows, keyExtractor: row => row.message.conversationId + ':' + row.message.id, keyboardShouldPersistTaps: "handled", ListHeaderComponent: _jsxs(View, { children: [directoryHeader, chats.length > 0 && _jsxs(_Fragment, { children: [_jsx(Text, { style: { paddingHorizontal: 16, paddingVertical: 8, color: c.secondary, fontSize: 14, fontWeight: '600' }, children: uiText("Chats") }), chats.map(chat => _jsx(Pressable, { accessibilityRole: "button", onPress: () => onSelect(chat), style: { minHeight: 48, paddingHorizontal: 16, justifyContent: 'center' }, children: _jsx(Text, { style: { color: c.foreground, fontSize: 16 }, children: name(chat) }) }, chat.id))] }), _jsx(Text, { style: { paddingHorizontal: 16, paddingVertical: 12, color: c.secondary, fontSize: 14, fontWeight: '600' }, children: uiText("Messages") })] }), ListEmptyComponent: !busy && !error ? _jsx(Text, { style: { padding: 16, color: c.secondary }, children: uiText("No matching messages.") }) : null, renderItem: ({ item }) => _jsxs(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText("Message in {value1}: {value2}", { value1: name(item.conversation), value2: item.message.text ?? '' }), onPress: () => onSelect(item.conversation, item.message.id), style: { paddingHorizontal: 16, paddingVertical: 12, gap: 5, borderBottomWidth: 1, borderBottomColor: c.foreground + '16' }, children: [_jsxs(View, { style: { flexDirection: 'row', gap: 8 }, children: [_jsx(Text, { numberOfLines: 1, style: { flex: 1, fontSize: 16, fontWeight: '600', color: c.foreground }, children: name(item.conversation) }), _jsx(Text, { style: { fontSize: 12, color: c.secondary }, children: new Date(item.message.createdAt).toLocaleDateString(uiLocale) })] }), _jsx(Text, { numberOfLines: 3, style: { fontSize: 15, lineHeight: 21, color: c.secondary }, children: item.message.text })] }), ListFooterComponent: _jsxs(View, { style: { minHeight: 48 }, children: [_jsx(View, { pointerEvents: "none", style: { position: "absolute", top: 0, left: 0, right: 0, height: 48, alignItems: "center", justifyContent: "center" }, children: busy && _jsx(ActivityIndicator, { accessibilityLabel: uiText("Searching all messages"), color: c.accent }) }), !!error && _jsxs(_Fragment, { children: [_jsx(Text, { accessibilityRole: "alert", style: { padding: 16, color: c.foreground }, children: error }), _jsx(Pressable, { accessibilityRole: "button", onPress: () => void search(rows.length > 0 && !!next), style: { minHeight: 44, paddingHorizontal: 16, justifyContent: 'center' }, children: _jsx(Text, { style: { color: c.accent }, children: uiText("Try again") }) })] }), next && !error && _jsx(Pressable, { disabled: busy, accessibilityState: { busy }, accessibilityRole: "button", onPress: () => void search(true), style: { minHeight: 48, alignItems: 'center', justifyContent: 'center' }, children: _jsx(Text, { style: { color: c.accent, opacity: busy ? 0 : 1 }, children: uiText("More results") }) })] }) }) });
66
70
  }
package/dist/inbox.d.ts CHANGED
@@ -9,6 +9,7 @@ export interface MessagingInboxProps extends MessagingDirectoryOptions {
9
9
  contacts?: Record<string, {
10
10
  name: string;
11
11
  avatarUrl?: string;
12
+ networkName?: string;
12
13
  groupEligible?: boolean;
13
14
  }>;
14
15
  onNewConversation?: () => void;
package/dist/inbox.js CHANGED
@@ -11,7 +11,7 @@ import { MessageMenuRow } from './message-menu.js';
11
11
  import { InboxMessageSearch } from './inbox-search.js';
12
12
  import { MessageIcon } from './icons.js';
13
13
  import { useEffect, useRef, useState, useSyncExternalStore } from 'react';
14
- import { AppState, FlatList, Image, Platform, Pressable, ScrollView, StyleSheet, View } from 'react-native';
14
+ import { ActivityIndicator, AppState, FlatList, Image, Platform, Pressable, ScrollView, StyleSheet, View } from 'react-native';
15
15
  import { defaultMessagingSettings } from '@robono/messaging';
16
16
  import { MessagingPopup, MessagingMenuSurface, MessagingPopupHeaderBoundary, useMessagingPopupColors, messagingPopupBackdrop } from './popup.js';
17
17
  /** Compact Messenger chat rows: avatar, name, last message, time and unread badge. */
@@ -81,21 +81,21 @@ export function MessagingInbox({ client, userId, selfAvatarUrl, contacts = {}, a
81
81
  setBusy(false);
82
82
  } }
83
83
  const preview = (row) => { const m = row.lastMessage; if (!m)
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; };
84
+ return row.deviceHistoryLastMessage ? uiText('Restore your backup to see earlier messages') : uiText('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; };
85
85
  if (directoryNavigation.selection)
86
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 }) => {
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(View, { style: { minHeight: 60, alignItems: 'center', justifyContent: 'center', paddingHorizontal: 20 }, children: state.loading ? _jsx(ActivityIndicator, { accessibilityLabel: uiText("Loading chats…"), color: c.secondary }) : _jsx(Text, { style: { textAlign: 'center', color: c.secondary }, children: state.error ? '' : query ? uiText("No matching chats.") : uiText("No chats yet") }) }), ListFooterComponent: state.hasMore ? _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText("More chats"), accessibilityState: { busy: state.loading }, disabled: state.loading, onPress: () => void client.loadMore().catch(() => { }), style: { minHeight: 48, alignItems: 'center', justifyContent: 'center' }, children: state.loading ? _jsx(ActivityIndicator, { color: c.accent }) : _jsx(Text, { style: { padding: 12, textAlign: 'center', color: c.accent }, children: uiText("More chats") }) }) : null, renderItem: ({ item: row }) => {
88
88
  if (row.kind === 'directory')
89
89
  return _jsx(MessagingDirectoryRow, { contact: row.entry, appearance: design, onPress: () => void openDirectory(row.entry) });
90
90
  const item = row.chat;
91
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';
92
- const date = item.lastMessage ? new Date(item.lastMessage.createdAt) : null;
92
+ const dateValue = item.lastMessage?.createdAt ?? item.deviceHistoryLastMessage?.createdAt, date = dateValue ? new Date(dateValue) : null;
93
93
  return _jsxs(Pressable, { ref: node => { if (node)
94
94
  rows.current.set(item.id, node);
95
95
  else
96
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')
97
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)
98
+ } }), onNewConversation && _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)
99
99
  setSelected(null); }, children: rect => {
100
100
  const palette = messagingMenuColors(design, 'friends'), menuLayout = messagingMenuLayout(design.menus?.friends);
101
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,7 @@
1
+ export { MessagingLinkedAppsScreen } from './linked-apps.js';
2
+ export type { MessagingLinkedApps, MessagingLinkedNetwork, MessagingLinkedContact } from './linked-apps.js';
3
+ export { messagingLanguages } from './account-pages.js';
4
+ export type { MessagingAccountPages, MessagingAccountPage } from './account-pages.js';
1
5
  export { messagingHeaderColors } from './header-colors.js';
2
6
  export { MessagingReviewInbox } from './reviews.js';
3
7
  export type { MessagingReviewInboxProps } from './reviews.js';
@@ -120,7 +124,8 @@ export interface MessagingScreenProps {
120
124
  contact: {
121
125
  name: string;
122
126
  avatarUrl?: string;
123
- language?: string;
127
+ language?: string; /** Authenticated directory label for this contact’s network. */
128
+ networkName?: string;
124
129
  };
125
130
  /** Resolve group member names through your app's authorized contact directory. */
126
131
  participants?: Record<string, {
@@ -217,8 +222,8 @@ export declare function MessageDeletion({ messages, onClose }: {
217
222
  export declare function MessagingList(): React.JSX.Element;
218
223
  export declare function MessagingComposer(): React.JSX.Element;
219
224
  /** Account navigation. Mount in the inbox/app toolbar, never in a contact menu. */
220
- export declare function MessagingAccountMenu({ inbox, onNewConversation, onNewGroup, onMaps, onPublicRooms }?: {
221
- inbox?: import('@robono/messaging').MessagingInboxClient;
225
+ export declare function MessagingAccountMenu({ inbox, onNewGroup, onMaps, onPublicRooms }?: {
226
+ inbox?: import('@robono/messaging').MessagingInboxClient; /** @deprecated Use MessagingInbox.onNewConversation for the floating Message button. */
222
227
  onNewConversation?: () => void;
223
228
  onNewGroup?: () => void;
224
229
  onMaps?: () => void;