@robono/messaging-react-native 0.23.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.
- package/CHANGELOG.md +27 -0
- package/README.md +157 -4
- package/RobonoMessagingRuntime.podspec +16 -0
- package/SBOM.spdx.json +2709 -813
- package/android/build.gradle +10 -0
- package/android/src/main/AndroidManifest.xml +1 -0
- package/android/src/main/java/com/robono/messaging/RobonoBackupCrypto.java +27 -0
- package/android/src/main/java/com/robono/messaging/RobonoBackupGoogle.java +76 -0
- package/android/src/main/java/com/robono/messaging/RobonoHistoryStore.java +173 -0
- package/android/src/main/java/com/robono/messaging/RobonoMessagingPackage.java +11 -0
- package/app.plugin.cjs +22 -3
- package/cloudkit/backup-schema.ckdb +13 -0
- package/dist/account-pages.d.ts +51 -0
- package/dist/account-pages.js +65 -0
- package/dist/account.d.ts +6 -2
- package/dist/account.js +37 -11
- package/dist/attachment-preview.d.ts +11 -10
- package/dist/attachment-preview.js +15 -12
- package/dist/backup-background.d.ts +25 -0
- package/dist/backup-background.js +71 -0
- package/dist/backup-base64.d.ts +3 -0
- package/dist/backup-base64.js +41 -0
- package/dist/backup-google-authorization.d.ts +23 -0
- package/dist/backup-google-authorization.js +95 -0
- package/dist/backup.d.ts +24 -0
- package/dist/backup.js +202 -0
- package/dist/brand.js +4 -4
- package/dist/bubble-design.d.ts +1 -1
- package/dist/bubble-design.js +5 -3
- package/dist/cloudkit-backup.d.ts +14 -0
- package/dist/cloudkit-backup.js +193 -0
- package/dist/contact-directory.d.ts +3 -1
- package/dist/contact-directory.js +3 -3
- package/dist/conversation-details.js +2 -2
- package/dist/customization.d.ts +1 -0
- package/dist/delivery-bar.d.ts +3 -2
- package/dist/delivery-bar.js +7 -4
- package/dist/delivery-notice.d.ts +9 -0
- package/dist/delivery-notice.js +15 -0
- package/dist/directory-navigation.d.ts +25 -0
- package/dist/directory-navigation.js +69 -0
- package/dist/expo-backup-background.d.ts +17 -0
- package/dist/expo-backup-background.js +57 -0
- package/dist/expo-backup-cloudkit.d.ts +6 -0
- package/dist/expo-backup-cloudkit.js +11 -0
- package/dist/expo-backup-crypto.d.ts +3 -0
- package/dist/expo-backup-crypto.js +17 -0
- package/dist/expo-backup-google.d.ts +7 -0
- package/dist/expo-backup-google.js +16 -0
- package/dist/expo-backup-network.d.ts +8 -0
- package/dist/expo-backup-network.js +18 -0
- package/dist/expo-backup-passkeys.d.ts +14 -0
- package/dist/expo-backup-passkeys.js +46 -0
- package/dist/expo-backup-settings.d.ts +4 -0
- package/dist/expo-backup-settings.js +59 -0
- package/dist/expo-backup.d.ts +14 -0
- package/dist/expo-backup.js +22 -0
- package/dist/expo-bridge.d.ts +2 -0
- package/dist/expo-bridge.js +3 -1
- package/dist/expo-cache.js +20 -1
- package/dist/expo-device-history.d.ts +24 -0
- package/dist/expo-device-history.js +88 -0
- package/dist/expo-durable-history.d.ts +26 -0
- package/dist/expo-durable-history.js +56 -0
- package/dist/expo-history-backup.d.ts +3 -0
- package/dist/expo-history-backup.js +79 -0
- package/dist/expo-history-maintenance.d.ts +4 -0
- package/dist/expo-history-maintenance.js +23 -0
- package/dist/expo-history-previews.d.ts +5 -0
- package/dist/expo-history-previews.js +57 -0
- package/dist/expo-history.d.ts +1 -1
- package/dist/expo-history.js +2 -2
- package/dist/expo-inbox-preferences.d.ts +3 -0
- package/dist/expo-inbox-preferences.js +9 -0
- package/dist/expo-media.d.ts +2 -0
- package/dist/expo-media.js +18 -24
- package/dist/expo-messenger.d.ts +8 -0
- package/dist/expo-messenger.js +27 -11
- package/dist/expo-notifications.d.ts +17 -1
- package/dist/expo-notifications.js +36 -16
- package/dist/expo-outbox.d.ts +2 -0
- package/dist/expo-outbox.js +1 -1
- package/dist/expo-oversight.d.ts +15 -0
- package/dist/expo-oversight.js +15 -0
- package/dist/expo-reviews.d.ts +6 -0
- package/dist/expo-reviews.js +145 -0
- package/dist/expo-screen.js +62 -28
- package/dist/expo-thumbnails.d.ts +6 -2
- package/dist/expo-thumbnails.js +73 -8
- package/dist/expo.d.ts +14 -0
- package/dist/expo.js +12 -0
- package/dist/forward.js +2 -2
- package/dist/header-calls.js +1 -1
- package/dist/header-colors.d.ts +5 -0
- package/dist/header-colors.js +7 -0
- package/dist/inbox-search.d.ts +1 -1
- package/dist/inbox-search.js +7 -3
- package/dist/inbox.d.ts +6 -2
- package/dist/inbox.js +27 -55
- package/dist/index.d.ts +14 -6
- package/dist/index.js +195 -78
- package/dist/linked-apps.d.ts +45 -0
- package/dist/linked-apps.js +40 -0
- package/dist/loading-messages.d.ts +5 -0
- package/dist/loading-messages.js +10 -0
- package/dist/media-access.d.ts +8 -0
- package/dist/media-access.js +6 -1
- package/dist/media-controller.d.ts +2 -0
- package/dist/native-history-authorization.d.ts +4 -0
- package/dist/native-history-authorization.js +69 -0
- package/dist/native-history-backup.d.ts +16 -0
- package/dist/native-history-backup.js +144 -0
- package/dist/native-history.d.ts +14 -0
- package/dist/native-history.js +186 -0
- package/dist/native-outbox.d.ts +2 -0
- package/dist/oversight-session.d.ts +4 -0
- package/dist/oversight-session.js +14 -0
- package/dist/popup.d.ts +6 -3
- package/dist/popup.js +6 -6
- package/dist/preview-layout.d.ts +12 -0
- package/dist/preview-layout.js +102 -0
- package/dist/recent-media.js +2 -1
- package/dist/reviews.d.ts +19 -0
- package/dist/reviews.js +231 -0
- package/dist/scheduled.js +6 -6
- package/dist/search.js +18 -8
- package/ios/RobonoBackupCloudKit.m +96 -0
- package/ios/RobonoBackupCrypto.m +30 -0
- package/ios/RobonoHistoryStore.m +170 -0
- package/package.json +34 -7
- package/plugin/backup-expiration.cjs +23 -0
- package/plugin/prepare-native.cjs +12 -0
|
@@ -0,0 +1,145 @@
|
|
|
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";
|
|
5
|
+
import { useAudioPlayer, useAudioPlayerStatus } from "expo-audio";
|
|
6
|
+
import { useVideoPlayer } from "expo-video";
|
|
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';
|
|
12
|
+
import { MessagingReviewInbox, } from "./reviews.js";
|
|
13
|
+
function ReviewVoice({ url, audio, foreground }) {
|
|
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]);
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
if (status.didJustFinish) {
|
|
24
|
+
stop();
|
|
25
|
+
void player.seekTo(0);
|
|
26
|
+
}
|
|
27
|
+
}, [player, status.didJustFinish]);
|
|
28
|
+
const label = !status.isLoaded
|
|
29
|
+
? "Loading recording…"
|
|
30
|
+
: status.playing
|
|
31
|
+
? "Pause recording"
|
|
32
|
+
: "Play recording";
|
|
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 })] }));
|
|
67
|
+
}
|
|
68
|
+
function ReviewVideo({ url, audio, foreground }) {
|
|
69
|
+
const player = useVideoPlayer(url, (p) => {
|
|
70
|
+
p.loop = false;
|
|
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 }) });
|
|
86
|
+
return (_jsx(MessengerVideoView, { player: player, nativeControls: true, style: { width: "100%", height: 240 } }));
|
|
87
|
+
}
|
|
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 })
|
|
140
|
+
: kind === "video"
|
|
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." }) }));
|
|
145
|
+
}
|
package/dist/expo-screen.js
CHANGED
|
@@ -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";
|
|
@@ -82,6 +83,7 @@ function VoicePlayer({ file, audio, design, inline, draft, autoPlay = false }) {
|
|
|
82
83
|
const reportPlayback = useContext(MediaPlayback);
|
|
83
84
|
const player = useAudioPlayer(source, { updateInterval: 100, downloadFirst: false, preferredForwardBufferDuration: 5, keepAudioSessionActive: true });
|
|
84
85
|
const mediaReady = useContext(MediaReadiness), recover = useContext(StreamRecovery);
|
|
86
|
+
const completed = useRef(false), resetting = useRef(null);
|
|
85
87
|
const recovered = useRef(false), lastPosition = useRef(file.resumeAtMs ?? 0), playIntent = useRef(file.autoPlay ?? autoPlay);
|
|
86
88
|
const [loaded, setLoaded] = useState(false);
|
|
87
89
|
autoPlay = file.autoPlay ?? autoPlay;
|
|
@@ -108,6 +110,8 @@ function VoicePlayer({ file, audio, design, inline, draft, autoPlay = false }) {
|
|
|
108
110
|
return true;
|
|
109
111
|
};
|
|
110
112
|
useEffect(() => {
|
|
113
|
+
player.loop = false;
|
|
114
|
+
completed.current = false;
|
|
111
115
|
const scope = voiceScope();
|
|
112
116
|
current.current = scope;
|
|
113
117
|
let started = false, reported = false, cancelled = false, autoPreparing = autoPlay;
|
|
@@ -143,22 +147,39 @@ function VoicePlayer({ file, audio, design, inline, draft, autoPlay = false }) {
|
|
|
143
147
|
fail(Error('Could not resume the recording.')); }); };
|
|
144
148
|
setLoaded(player.isLoaded);
|
|
145
149
|
restorePaused();
|
|
146
|
-
const subscription = player.addListener('playbackStatusUpdate', status => {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
150
|
+
const subscription = player.addListener('playbackStatusUpdate', status => {
|
|
151
|
+
if (!scope.alive)
|
|
152
|
+
return;
|
|
153
|
+
setLoaded(status.isLoaded);
|
|
154
|
+
if (status.didJustFinish) {
|
|
155
|
+
if (completed.current)
|
|
156
|
+
return;
|
|
157
|
+
completed.current = true;
|
|
158
|
+
cancelled = true;
|
|
159
|
+
started = true;
|
|
160
|
+
scope.epoch++;
|
|
161
|
+
clearTimeout(startupTimeout);
|
|
162
|
+
if (!draft)
|
|
163
|
+
reportPlayback(file.uri, { positionMs: player.duration * 1000, durationMs: player.duration * 1000, playing: false, ended: true, activeView: AppState.currentState === 'active' });
|
|
164
|
+
// Seeking a still-running native player to zero can restart it. Stop first;
|
|
165
|
+
// ordinary Pause never takes this path or changes the playback position.
|
|
166
|
+
playIntent.current = false;
|
|
167
|
+
player.pause();
|
|
168
|
+
lastPosition.current = 0;
|
|
169
|
+
setPosition(0);
|
|
170
|
+
setPlaying(false);
|
|
171
|
+
resetting.current = player.seekTo(0).catch(() => { });
|
|
172
|
+
void releaseVoice(scope);
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
if ('error' in status && status.error) {
|
|
176
|
+
if (!recoverStream())
|
|
177
|
+
fail(Error('The recording could not be played. Try again.'));
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
restorePaused();
|
|
181
|
+
begin();
|
|
182
|
+
});
|
|
162
183
|
voiceStops.add(stop);
|
|
163
184
|
if (autoPlay) {
|
|
164
185
|
scope.busy = true;
|
|
@@ -184,7 +205,7 @@ function VoicePlayer({ file, audio, design, inline, draft, autoPlay = false }) {
|
|
|
184
205
|
} });
|
|
185
206
|
}
|
|
186
207
|
const timer = setInterval(() => {
|
|
187
|
-
if (!scope.alive)
|
|
208
|
+
if (!scope.alive || completed.current)
|
|
188
209
|
return;
|
|
189
210
|
if (!draft)
|
|
190
211
|
reportPlayback(file.uri, { positionMs: player.currentTime * 1000, durationMs: player.duration * 1000, playing: player.playing, activeView: AppState.currentState === 'active', rate: player.playbackRate });
|
|
@@ -232,8 +253,11 @@ function VoicePlayer({ file, audio, design, inline, draft, autoPlay = false }) {
|
|
|
232
253
|
await releaseVoice(scope);
|
|
233
254
|
return;
|
|
234
255
|
}
|
|
235
|
-
if (
|
|
256
|
+
if (completed.current) {
|
|
257
|
+
await resetting.current;
|
|
236
258
|
await player.seekTo(0);
|
|
259
|
+
completed.current = false;
|
|
260
|
+
}
|
|
237
261
|
playIntent.current = true;
|
|
238
262
|
player.play();
|
|
239
263
|
}
|
|
@@ -252,7 +276,7 @@ function VoicePlayer({ file, audio, design, inline, draft, autoPlay = false }) {
|
|
|
252
276
|
const duration = file.durationMs ?? player.duration * 1000;
|
|
253
277
|
if (draft)
|
|
254
278
|
return _jsx(VoiceDraftPlayback, { compact: draft.compact, appearance: design, playing: playing, positionMs: position, durationMs: duration, waveform: draft.waveform, onToggle: () => void toggle(), onRemove: draft.onRemove, disabled: draft.disabled, error: error });
|
|
255
|
-
return _jsx(VoicePlayback, { message: inline?.message, mine: inline?.mine, heard: inline?.heard, onPlayed: inline?.onPlayed, background: inline?.background, ink: inline?.ink ?? c.foreground, accent: inline?.accent ?? c.accent, waveform: inline?.waveform, showWaveform: inline?.showWaveform, footer: inline?.footer, onLongPress: inline?.onLongPress, durationMs: duration, positionMs: position, playing: playing, loading: !!file.stream && !loaded && !error, error: error, onToggle: () => void toggle(), onSeek: ms => { lastPosition.current = Math.max(0, Math.min(duration, ms)); void player.seekTo(lastPosition.current / 1000).catch(() => { if (!recoverStream())
|
|
279
|
+
return _jsx(VoicePlayback, { message: inline?.message, mine: inline?.mine, heard: inline?.heard, onPlayed: inline?.onPlayed, background: inline?.background, ink: inline?.ink ?? c.foreground, accent: inline?.accent ?? c.accent, waveform: inline?.waveform, showWaveform: inline?.showWaveform, footer: inline?.footer, onLongPress: inline?.onLongPress, durationMs: duration, positionMs: position, playing: playing, loading: !!file.stream && !loaded && !error, error: error, onToggle: () => void toggle(), onSeek: ms => { completed.current = false; lastPosition.current = Math.max(0, Math.min(duration, ms)); void player.seekTo(lastPosition.current / 1000).catch(() => { if (!recoverStream())
|
|
256
280
|
setError(uiText("Could not seek. Try again.")); }); } });
|
|
257
281
|
}
|
|
258
282
|
function VideoPlayer({ file, audio, posterUri }) {
|
|
@@ -465,17 +489,27 @@ function ExpoMessagingScreenContent({ storage, audioSession, renderConversation,
|
|
|
465
489
|
controller.restorePrepared(media.assetId, copy, kind);
|
|
466
490
|
return copy;
|
|
467
491
|
}, [controller, recorder, props.client, outbox, audioSession]);
|
|
468
|
-
const
|
|
469
|
-
|
|
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]);
|
|
493
|
+
const prepare = async (kind, media) => {
|
|
494
|
+
await restore(media, kind);
|
|
495
|
+
const owner = recorder.getPrepared(media.assetId) ? recorder : controller;
|
|
496
|
+
if (!owner.getPrepared(media.assetId))
|
|
497
|
+
return media;
|
|
498
|
+
const conversationId = props.client.getSnapshot().conversationId;
|
|
499
|
+
const preparedPreview = thumbnails.preview({ id: 'pending:' + media.assetId, conversationId, kind, media });
|
|
500
|
+
const uploaded = await owner.uploadPrepared(media.assetId, kind);
|
|
501
|
+
if (props.client.getSnapshot().conversationId === conversationId)
|
|
502
|
+
thumbnails.retainUpload(conversationId, uploaded, await preparedPreview);
|
|
503
|
+
return uploaded;
|
|
504
|
+
};
|
|
470
505
|
useEffect(() => props.client.setAttachmentPreparer(async (content) => { if (!content.media || content.kind === 'text' || content.kind === 'poll' || !await restore(content.media, content.kind))
|
|
471
|
-
throw Error('The saved attachment is unavailable. Remove it and choose it again.'); return { ...content, media: await prepare(content.kind, content.media) }; }), [props.client, controller, recorder, outbox]);
|
|
472
|
-
const thumbnails = useMemo(() => createExpoThumbnails(recent.storage, id => controller.getPrepared(id) ?? recorder.getPrepared(id), createExpoMessagingDevice(audioSession).remove), [recent, controller, recorder, audioSession]);
|
|
506
|
+
throw Error('The saved attachment is unavailable. Remove it and choose it again.'); return { ...content, media: await prepare(content.kind, content.media) }; }), [props.client, controller, recorder, outbox, thumbnails]);
|
|
473
507
|
const thumbnailAccess = JSON.stringify([state.settings?.enabled, state.settings?.features, state.conversation?.canSend, !!state.error]);
|
|
474
508
|
useEffect(() => () => thumbnails.clear(), [thumbnails, state.conversationId, thumbnailAccess, props.active]);
|
|
475
509
|
useEffect(() => { const sub = AppState.addEventListener('change', value => { if (value !== 'active')
|
|
476
510
|
thumbnails.clear(); }); return () => sub.remove(); }, [thumbnails]);
|
|
477
511
|
const cacheDisposal = useRef(new Map());
|
|
478
|
-
|
|
512
|
+
useLayoutEffect(() => {
|
|
479
513
|
clearTimeout(cacheDisposal.current.get(recent));
|
|
480
514
|
cacheDisposal.current.delete(recent);
|
|
481
515
|
const sync = () => { const snapshot = props.client.getSnapshot(); if (preloadRecentMedia && current.current.active !== false && snapshot.settings?.enabled && !snapshot.error && AppState.currentState === 'active')
|
|
@@ -552,9 +586,9 @@ function ExpoMessagingScreenContent({ storage, audioSession, renderConversation,
|
|
|
552
586
|
}, []);
|
|
553
587
|
return ready ? _jsx(ExpoSocialPlayer, { ...ui }) : null;
|
|
554
588
|
}, [audioSession]);
|
|
555
|
-
useEffect(() => saved?.bindDownload(async (m) => { const device = createExpoMessagingDevice(audioSession), file = await storage.download(m, { signal
|
|
556
|
-
const attachmentPreview =
|
|
557
|
-
await restore(m.media, m.kind); return thumbnails.preview(m, options); }, [restore, thumbnails]);
|
|
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]);
|
|
590
|
+
const attachmentPreview = useMemo(() => Object.assign(async (m, options) => { if (m.media && m.kind !== 'text' && m.kind !== 'poll')
|
|
591
|
+
await restore(m.media, m.kind); return thumbnails.preview(m, options); }, { peek: thumbnails.peek }), [restore, thumbnails]);
|
|
558
592
|
const defaultQuoteReady = useCallback(() => { if (Platform.OS === 'android')
|
|
559
593
|
Vibration.vibrate(8);
|
|
560
594
|
else if (Platform.OS === 'ios')
|
|
@@ -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<{}>;
|
|
@@ -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
|
};
|
package/dist/expo-thumbnails.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
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';
|
|
4
5
|
import * as FS from 'expo-file-system/legacy';
|
|
6
|
+
import { Image } from 'react-native';
|
|
5
7
|
/** Small local previews, with bounded downloads and memory. Large originals stay
|
|
6
8
|
* tap-to-open until the storage service supplies a dedicated thumbnail. */
|
|
7
|
-
export function createExpoThumbnails(storage, local, remove) {
|
|
9
|
+
export function createExpoThumbnails(storage, local, remove, history) {
|
|
8
10
|
const cache = new MessagingPreviewCache();
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
+
const saving = new MessagingPreviewCache({ concurrency: 1, maximum: 8, ttlMs: 60000, timeoutMs: 3000 });
|
|
12
|
+
const clear = () => { cache.clear(); saving.clear(); };
|
|
13
|
+
const keyFor = (message) => JSON.stringify([message.conversationId, message.media?.assetId, message.revision ?? 0, message.media]);
|
|
11
14
|
function preview(message, options) {
|
|
12
15
|
const media = message.media;
|
|
13
16
|
if (!media || message.deleted)
|
|
@@ -17,11 +20,18 @@ export function createExpoThumbnails(storage, local, remove) {
|
|
|
17
20
|
if (!['image', 'video'].includes(message.kind))
|
|
18
21
|
return Promise.resolve({});
|
|
19
22
|
const id = media.assetId, key = keyFor(message);
|
|
20
|
-
if (options?.refresh)
|
|
23
|
+
if (options?.refresh) {
|
|
21
24
|
cache.invalidate(key);
|
|
25
|
+
saving.invalidate(key);
|
|
26
|
+
}
|
|
22
27
|
return cache.get(key, async (signal) => {
|
|
23
28
|
if (signal.aborted)
|
|
24
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 };
|
|
25
35
|
let file = local(id), downloaded = false, poster, thumbnail;
|
|
26
36
|
// An optimistic bubble has no server message ID yet. Only its local file can
|
|
27
37
|
// supply a preview until acknowledgement replaces the pending bubble.
|
|
@@ -29,19 +39,27 @@ export function createExpoThumbnails(storage, local, remove) {
|
|
|
29
39
|
return {};
|
|
30
40
|
try {
|
|
31
41
|
let dedicated = false;
|
|
32
|
-
if (!file && storage.thumbnail) {
|
|
33
|
-
file = await storage.thumbnail(message, { signal, onProgress: () => { } }) ?? undefined;
|
|
42
|
+
if (!file && storage.thumbnail && !useSmallOriginalPreview(message)) {
|
|
43
|
+
file = await storage.thumbnail(message, { signal, purpose: 'preview', onProgress: () => { } }) ?? undefined;
|
|
34
44
|
dedicated = !!file;
|
|
35
45
|
downloaded = !!file;
|
|
36
46
|
}
|
|
37
47
|
if (!file) {
|
|
38
48
|
if (media.byteSize > 2 * 1024 * 1024)
|
|
39
49
|
return {};
|
|
40
|
-
file = await storage.download(message, { signal:
|
|
50
|
+
file = await storage.download(message, { signal, purpose: 'preview', onProgress: () => { } });
|
|
41
51
|
downloaded = true;
|
|
42
52
|
}
|
|
43
53
|
if (signal.aborted)
|
|
44
54
|
return {};
|
|
55
|
+
// A server thumbnail or small original JPEG is already bounded. Re-encoding adds
|
|
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 };
|
|
59
|
+
if (dedicated || message.kind === 'image' && isSmallMessagingJpeg(file)) {
|
|
60
|
+
const base64 = await FS.readAsStringAsync(file.uri, { encoding: FS.EncodingType.Base64 });
|
|
61
|
+
return signal.aborted ? {} : { uri: 'data:image/jpeg;base64,' + base64 };
|
|
62
|
+
}
|
|
45
63
|
if (message.kind === 'video' && !dedicated)
|
|
46
64
|
poster = (await VideoThumbnails.getThumbnailAsync(file.uri, { time: 0, quality: .6 })).uri;
|
|
47
65
|
const result = await ImageManipulator.manipulateAsync(poster ?? file.uri, [{ resize: { width: 480 } }], { compress: .7, format: ImageManipulator.SaveFormat.JPEG, base64: true });
|
|
@@ -55,8 +73,55 @@ export function createExpoThumbnails(storage, local, remove) {
|
|
|
55
73
|
if (uri && FS.cacheDirectory && uri.startsWith(FS.cacheDirectory))
|
|
56
74
|
await FS.deleteAsync(uri, { idempotent: true }).catch(() => { });
|
|
57
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;
|
|
58
108
|
});
|
|
59
109
|
}
|
|
60
110
|
// Uploaded IDs get their own authorized preview; never alias access between assets.
|
|
61
|
-
|
|
111
|
+
const peek = (message) => {
|
|
112
|
+
if (message.deleted)
|
|
113
|
+
return undefined;
|
|
114
|
+
const cached = cache.peek(keyFor(message));
|
|
115
|
+
if (cached)
|
|
116
|
+
return cached;
|
|
117
|
+
const file = message.kind === 'image' && message.media ? local(message.media.assetId) : undefined;
|
|
118
|
+
return file ? { uri: file.uri } : undefined;
|
|
119
|
+
};
|
|
120
|
+
// Only the owning upload can transfer its prepared preview to the accepted
|
|
121
|
+
// asset. Received assets continue through their own authorization path.
|
|
122
|
+
const retainUpload = (conversationId, media, value) => {
|
|
123
|
+
if (value.uri)
|
|
124
|
+
void cache.get(keyFor({ conversationId, media }), async () => value);
|
|
125
|
+
};
|
|
126
|
+
return { preview, clear, peek, retainUpload };
|
|
62
127
|
}
|
package/dist/expo.d.ts
CHANGED
|
@@ -5,3 +5,17 @@ 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 { createExpoMessagingBackup } from './expo-backup.js';
|
|
12
|
+
export { createExpoCloudKitMessagingBackup } from './expo-backup-cloudkit.js';
|
|
13
|
+
export { createExpoGoogleMessagingBackup } from './expo-backup-google.js';
|
|
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
|
@@ -4,3 +4,15 @@ 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 { createExpoMessagingBackup } from './expo-backup.js';
|
|
11
|
+
export { createExpoCloudKitMessagingBackup } from './expo-backup-cloudkit.js';
|
|
12
|
+
export { createExpoGoogleMessagingBackup } from './expo-backup-google.js';
|
|
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';
|
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;
|
package/dist/header-calls.js
CHANGED
|
@@ -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:
|
|
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');
|
|
@@ -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-search.d.ts
CHANGED
|
@@ -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
|
|
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;
|
package/dist/inbox-search.js
CHANGED
|
@@ -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
|
|
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)
|
|
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
|
|
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
|
@@ -1,15 +1,19 @@
|
|
|
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;
|
|
12
|
+
networkName?: string;
|
|
11
13
|
groupEligible?: boolean;
|
|
12
14
|
}>;
|
|
15
|
+
onNewConversation?: () => void;
|
|
16
|
+
onDirectorySelect?: (contact: MessagingDirectoryContact) => void;
|
|
13
17
|
viewMemory?: InboxViewMemory;
|
|
14
18
|
query?: string;
|
|
15
19
|
onSearchChange?: (value: string) => void;
|
|
@@ -24,4 +28,4 @@ export interface MessagingInboxProps extends MessagingDirectoryOptions {
|
|
|
24
28
|
onDeleted?: (conversationId: string) => Promise<void> | void;
|
|
25
29
|
}
|
|
26
30
|
/** 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;
|
|
31
|
+
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;
|