@robono/messaging-react-native 0.20.3 → 0.22.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 +5 -1
- package/README.md +58 -0
- package/SBOM.spdx.json +478 -238
- package/app.plugin.cjs +9 -3
- package/dist/bubble-design.d.ts +12 -0
- package/dist/bubble-design.js +11 -0
- package/dist/call-message.js +39 -9
- package/dist/delivery-bar.d.ts +7 -0
- package/dist/delivery-bar.js +19 -0
- package/dist/disk-cache.d.ts +14 -0
- package/dist/disk-cache.js +15 -0
- package/dist/expo-cache.d.ts +20 -0
- package/dist/expo-cache.js +111 -0
- package/dist/expo-calling.d.ts +1 -1
- package/dist/expo-calling.js +1 -1
- package/dist/expo-media.js +7 -22
- package/dist/expo-messenger.js +12 -3
- package/dist/expo-notification-cleanup.d.ts +7 -0
- package/dist/expo-notification-cleanup.js +96 -0
- package/dist/expo-notifications.d.ts +1 -0
- package/dist/expo-notifications.js +38 -8
- package/dist/expo-screen.js +16 -8
- package/dist/expo-thumbnails.d.ts +4 -0
- package/dist/expo-thumbnails.js +3 -2
- package/dist/expo.d.ts +1 -0
- package/dist/expo.js +1 -0
- package/dist/inbox.d.ts +2 -1
- package/dist/inbox.js +4 -3
- package/dist/index.js +21 -20
- package/dist/media-controller.d.ts +2 -1
- package/dist/media-controller.js +8 -8
- package/dist/media-ui.d.ts +4 -2
- package/dist/media-ui.js +13 -13
- package/dist/message-order.d.ts +2 -2
- package/dist/message-order.js +2 -2
- package/dist/preview-cache.d.ts +1 -0
- package/dist/preview-cache.js +2 -0
- package/dist/voice-composer.js +2 -1
- package/dist/voice-waveform.d.ts +2 -0
- package/dist/voice-waveform.js +9 -0
- package/package.json +12 -6
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import * as Notifications from 'expo-notifications';
|
|
2
2
|
import * as Crypto from 'expo-crypto';
|
|
3
3
|
import * as SecureStore from 'expo-secure-store';
|
|
4
|
-
import { Platform } from 'react-native';
|
|
5
|
-
import {
|
|
4
|
+
import { Platform, AppState } from 'react-native';
|
|
5
|
+
import { notificationData, presentedNotificationData, dismissReadNotification, notificationWasRead, rememberNotificationAccount, registerNotificationCleanup } from './expo-notification-cleanup.js';
|
|
6
|
+
import { createMessagingNotificationRouter, parseMessagingNotification, parseMessagingReadNotification } from '@robono/messaging';
|
|
6
7
|
/** One restored account. Never prompts on mount, replaces a global handler or opens an unverified call. */
|
|
7
8
|
export async function connectExpoMessagingNotifications(options) {
|
|
8
9
|
if (!['ios', 'android'].includes(Platform.OS))
|
|
@@ -31,6 +32,7 @@ export async function connectExpoMessagingNotifications(options) {
|
|
|
31
32
|
if (status.userId !== options.userId || typeof status.accountScope !== 'string' || !/^[a-f\d]{64}$/.test(status.accountScope))
|
|
32
33
|
throw Error('The notification session does not match the signed-in account.');
|
|
33
34
|
accountScope = status.accountScope;
|
|
35
|
+
await rememberNotificationAccount(status.accountScope, true);
|
|
34
36
|
const router = createMessagingNotificationRouter({ accountScope: status.accountScope, authorize: options.authorize, open: options.open, refresh: options.refresh });
|
|
35
37
|
const register = (token) => {
|
|
36
38
|
lastToken = token;
|
|
@@ -49,8 +51,11 @@ export async function connectExpoMessagingNotifications(options) {
|
|
|
49
51
|
await options.systemCalls.configure(status.accountScope, () => { if (lastToken && !closing && !disposed)
|
|
50
52
|
void register(lastToken).catch(options.onError); });
|
|
51
53
|
const tokenListener = Notifications.addPushTokenListener(token => { void register(token).catch(options.onError); });
|
|
52
|
-
const handle = async (
|
|
53
|
-
return false; if (data.accountScope === accountScope &&
|
|
54
|
+
const handle = async (raw, opened = false) => { const data = notificationData(raw); if (!data || disposed || closing)
|
|
55
|
+
return false; if (data.accountScope === accountScope && await dismissReadNotification(data)) {
|
|
56
|
+
await options.refresh();
|
|
57
|
+
return true;
|
|
58
|
+
} if (data.accountScope === accountScope && ['calling.incoming', 'calling.dismissed', 'calling.group_incoming', 'calling.group_dismissed'].includes(String(data.event)) && options.onCall) {
|
|
54
59
|
if (String(data.event).endsWith('dismissed')) {
|
|
55
60
|
const shown = await Notifications.getPresentedNotificationsAsync();
|
|
56
61
|
await Promise.all(shown.filter(n => n.request.content.data?.accountScope === accountScope && n.request.content.data?.call_id === data.call_id).map(n => Notifications.dismissNotificationAsync(n.request.identifier)));
|
|
@@ -68,6 +73,22 @@ export async function connectExpoMessagingNotifications(options) {
|
|
|
68
73
|
}
|
|
69
74
|
};
|
|
70
75
|
const opened = Notifications.addNotificationResponseReceivedListener(value => { void response(value).catch(options.onError); });
|
|
76
|
+
let reconciling;
|
|
77
|
+
const reconcile = () => reconciling ??= (async () => {
|
|
78
|
+
if (disposed || closing)
|
|
79
|
+
return;
|
|
80
|
+
const shown = (await Notifications.getPresentedNotificationsAsync()).map(n => ({ id: n.request.identifier, event: parseMessagingNotification(presentedNotificationData(n)) })).filter(n => n.event?.accountScope === accountScope);
|
|
81
|
+
for (let i = 0; i < shown.length; i += 100) {
|
|
82
|
+
const batch = shown.slice(i, i + 100), result = await request({ operation: 'notification-reconcile', messages: batch.map(n => ({ conversationId: n.event.conversationId, messageId: n.event.messageId })) });
|
|
83
|
+
if (disposed || closing || result.accountScope !== accountScope || !Array.isArray(result.stale))
|
|
84
|
+
return;
|
|
85
|
+
for (const n of batch)
|
|
86
|
+
if (result.stale.some((m) => m.conversationId === n.event.conversationId && m.messageId === n.event.messageId))
|
|
87
|
+
await Notifications.dismissNotificationAsync(n.id);
|
|
88
|
+
}
|
|
89
|
+
})().finally(() => { reconciling = undefined; });
|
|
90
|
+
const foreground = AppState.addEventListener('change', state => { if (state === 'active')
|
|
91
|
+
void reconcile().catch(options.onError); });
|
|
71
92
|
const ready = (async () => {
|
|
72
93
|
if (Platform.OS === 'android') {
|
|
73
94
|
await Notifications.setNotificationChannelAsync('robono-messages', { name: 'Messages', importance: Notifications.AndroidImportance.HIGH });
|
|
@@ -76,12 +97,14 @@ export async function connectExpoMessagingNotifications(options) {
|
|
|
76
97
|
}
|
|
77
98
|
if ((await Notifications.getPermissionsAsync()).granted)
|
|
78
99
|
await register(await Notifications.getDevicePushTokenAsync());
|
|
100
|
+
await registerNotificationCleanup();
|
|
79
101
|
await response(await Notifications.getLastNotificationResponseAsync());
|
|
102
|
+
await reconcile();
|
|
80
103
|
})();
|
|
81
104
|
void ready.catch(options.onError);
|
|
82
|
-
const dispose = () => { disposed = true; router.dispose(); tokenListener.remove(); received.remove(); opened.remove(); void options.systemCalls?.disconnect().catch(options.onError); };
|
|
105
|
+
const dispose = () => { disposed = true; router.dispose(); tokenListener.remove(); received.remove(); opened.remove(); foreground.remove(); void options.systemCalls?.disconnect().catch(options.onError); };
|
|
83
106
|
return {
|
|
84
|
-
ready,
|
|
107
|
+
ready, reconcile,
|
|
85
108
|
/** Call only after the user chooses Enable notifications in your interface. */
|
|
86
109
|
async enable() { if (disposed || closing)
|
|
87
110
|
return false; const permission = await Notifications.requestPermissionsAsync(); if (!permission.granted)
|
|
@@ -92,7 +115,12 @@ export async function connectExpoMessagingNotifications(options) {
|
|
|
92
115
|
await request({ operation: 'remove-device', deviceId });
|
|
93
116
|
}
|
|
94
117
|
finally {
|
|
95
|
-
|
|
118
|
+
try {
|
|
119
|
+
await rememberNotificationAccount(accountScope, false);
|
|
120
|
+
}
|
|
121
|
+
finally {
|
|
122
|
+
dispose();
|
|
123
|
+
}
|
|
96
124
|
} },
|
|
97
125
|
dispose,
|
|
98
126
|
};
|
|
@@ -100,7 +128,9 @@ export async function connectExpoMessagingNotifications(options) {
|
|
|
100
128
|
/** Compose with the host's existing handler. Suppress only this account's open conversation. */
|
|
101
129
|
export function withMessagingNotificationPresentation(handler, current) {
|
|
102
130
|
return { ...handler, handleNotification: async (notification) => {
|
|
103
|
-
const
|
|
131
|
+
const data = notificationData(notification.request.content.data), event = parseMessagingNotification(data), active = current();
|
|
132
|
+
if (parseMessagingReadNotification(data) || await notificationWasRead(data))
|
|
133
|
+
return { shouldPlaySound: false, shouldSetBadge: false, shouldShowBanner: false, shouldShowList: false };
|
|
104
134
|
if (event && (event.accountScope !== active.accountScope || event.conversationId === active.conversationId))
|
|
105
135
|
return { shouldPlaySound: false, shouldSetBadge: false, shouldShowBanner: false, shouldShowList: false };
|
|
106
136
|
return handler.handleNotification(notification);
|
package/dist/expo-screen.js
CHANGED
|
@@ -142,7 +142,15 @@ function VoicePlayer({ file, audio, design, inline, draft, autoPlay = false }) {
|
|
|
142
142
|
setLoaded(player.isLoaded);
|
|
143
143
|
restorePaused();
|
|
144
144
|
const subscription = player.addListener('playbackStatusUpdate', status => { if (!scope.alive)
|
|
145
|
-
return; setLoaded(status.isLoaded); if (
|
|
145
|
+
return; setLoaded(status.isLoaded); if (status.didJustFinish) {
|
|
146
|
+
playIntent.current = false;
|
|
147
|
+
lastPosition.current = 0;
|
|
148
|
+
setPosition(0);
|
|
149
|
+
setPlaying(false);
|
|
150
|
+
void player.seekTo(0).catch(() => { });
|
|
151
|
+
void releaseVoice(scope);
|
|
152
|
+
return;
|
|
153
|
+
} if ('error' in status && status.error) {
|
|
146
154
|
if (!recoverStream())
|
|
147
155
|
fail(Error('The recording could not be played. Try again.'));
|
|
148
156
|
return;
|
|
@@ -240,13 +248,13 @@ function VoicePlayer({ file, audio, design, inline, draft, autoPlay = false }) {
|
|
|
240
248
|
return _jsx(VoicePlayback, { message: inline?.message, mine: inline?.mine, heard: inline?.heard, onPlayed: inline?.onPlayed, background: inline?.background, ink: inline?.ink ?? c.foreground, accent: inline?.accent ?? c.accent, waveform: inline?.waveform, showWaveform: inline?.showWaveform, footer: inline?.footer, onLongPress: inline?.onLongPress, durationMs: duration, positionMs: position, playing: playing, loading: !!file.stream && !loaded && !error, error: error, onToggle: () => void toggle(), onSeek: ms => { lastPosition.current = Math.max(0, Math.min(duration, ms)); void player.seekTo(lastPosition.current / 1000).catch(() => { if (!recoverStream())
|
|
241
249
|
setError(uiText("Could not seek. Try again.")); }); } });
|
|
242
250
|
}
|
|
243
|
-
function VideoPlayer({ file, audio }) {
|
|
251
|
+
function VideoPlayer({ file, audio, posterUri }) {
|
|
244
252
|
const { text: uiText, locale: uiLocale, number: uiNumber, count: uiCount } = useRobonoLocale();
|
|
245
253
|
const mediaReady = useContext(MediaReadiness), recover = useContext(StreamRecovery);
|
|
246
254
|
const source = useMemo(() => file.stream ? { uri: file.uri, headers: file.stream.headers, contentType: 'progressive', useCaching: false } : file.uri, [file]);
|
|
247
255
|
const player = useVideoPlayer(source, p => { p.loop = false; p.audioMixingMode = 'mixWithOthers'; if (file.stream)
|
|
248
256
|
p.bufferOptions = { preferredForwardBufferDuration: 5, minBufferForPlayback: 0.5 }; });
|
|
249
|
-
const [ready, setReady] = useState(false), [error, setError] = useState('');
|
|
257
|
+
const [ready, setReady] = useState(false), [error, setError] = useState(''), [frameReady, setFrameReady] = useState(false);
|
|
250
258
|
const desired = useRef(file.autoPlay ?? true), lastPosition = useRef(file.resumeAtMs ?? 0);
|
|
251
259
|
useEffect(() => {
|
|
252
260
|
let alive = true, recovered = false, audioReady = false, resumed = false, release;
|
|
@@ -313,7 +321,7 @@ function VideoPlayer({ file, audio }) {
|
|
|
313
321
|
}
|
|
314
322
|
catch { } void release?.().catch(() => { }); };
|
|
315
323
|
}, [player, audio]);
|
|
316
|
-
return _jsxs(View, { style: { flex: 1, minHeight: 0 }, children: [_jsx(MessengerVideoView, { testID: "messenger-video-player", onFirstFrameRender: () => mediaReady('video-frame', file.uri), player: player, nativeControls: ready, style: { height: '100%', width: '100%' } }), !!error && _jsx(Text, { accessibilityRole: "alert", style: { position: 'absolute', bottom: 12, left: 12, right: 12, color: '#fff', backgroundColor: '#000c', padding: 12 }, children: error })] });
|
|
324
|
+
return _jsxs(View, { style: { flex: 1, minHeight: 0 }, children: [_jsx(MessengerVideoView, { posterUri: posterUri, testID: "messenger-video-player", onFirstFrameRender: () => { setFrameReady(true); mediaReady('video-frame', file.uri); }, player: player, nativeControls: ready, style: { height: '100%', width: '100%' } }), posterUri && !frameReady && _jsx(View, { pointerEvents: "none", style: { position: 'absolute', width: '100%', height: '100%' }, children: _jsx(Image, { testID: "video-loading-preview", source: { uri: posterUri }, resizeMode: "contain", style: { width: '100%', height: '100%' } }) }), !!error && _jsx(Text, { accessibilityRole: "alert", style: { position: 'absolute', bottom: 12, left: 12, right: 12, color: '#fff', backgroundColor: '#000c', padding: 12 }, children: error })] });
|
|
317
325
|
}
|
|
318
326
|
function FileViewer({ file, kind, audio, design }) {
|
|
319
327
|
const { text: uiText, locale: uiLocale, number: uiNumber, count: uiCount } = useRobonoLocale();
|
|
@@ -387,7 +395,7 @@ export function MessagingMediaOverlay({ controller, audio, appearance, inlineVoi
|
|
|
387
395
|
if ((typeof inlineVoice === 'function' ? inlineVoice() : inlineVoice) && state.kind === 'voice' && ['opening', 'viewing', 'failed'].includes(state.phase) && !review)
|
|
388
396
|
return null;
|
|
389
397
|
const actions = !review ? viewerActions?.() : undefined;
|
|
390
|
-
const viewer = (state.file && (review || state.phase === 'viewing') || ['opening', 'failed'].includes(state.phase) && ['image', 'video', 'document'].includes(state.kind)) ? _jsx(MediaViewer, { showDelete: !review && enabled('delete'), showForward: !review && enabled('forward'), loading: state.phase === 'opening', expanded: expanded, onExpandedChange: setExpanded, keepControlsVisible: mediaViewer?.keepControlsVisible ?? appearance.mediaViewer?.keepControlsVisible, status: status, kind: state.kind, uri: state.file?.uri, title: review ? uiText('Preview attachment') : state.kind === 'image' ? uiText('Photo') : state.kind === 'video' ? uiText('Video') : state.kind === 'voice' ? uiText('Voice message') : uiText('File'), subtitle: state.file?.fileName, fileName: state.file?.fileName, byteSize: state.file?.byteSize, error: state.error ?? fileError, onClose: () => { setFileError(''); void controller.cancel(); }, reviewAction: review ? (state.phase === 'failed' ? 'Retry upload' : 'Add attachment') : undefined, onReview: review ? () => void controller.send() : undefined, downloading: downloading, transferProgress: downloading ? state.progress : undefined, onForward: actions?.onForward && enabled('forward') ? () => perform('forward', actions.onForward) : undefined, onDelete: actions?.onDelete && enabled('delete') ? () => perform('delete', actions.onDelete) : undefined, onDownload: !review && enabled('download') && ['image', 'video', 'document'].includes(state.kind) ? () => perform('download') : undefined, onShare: !review && enabled('share') ? () => perform('share') : undefined, children: !state.file ? null : state.kind === 'document' ? _jsx(ExpoDocumentPreview, { file: state.file, onOpenLink: onDocumentLink }) : state.kind === 'video' ? _jsx(VideoPlayer, { file: state.file, audio: audio, design: appearance }, state.file.uri) : state.kind === 'voice' ? _jsx(View, { style: { flex: 1, justifyContent: 'center', alignItems: 'center', padding: 20 }, children: _jsx(VoicePlayer, { file: state.file, audio: audio, design: { ...appearance, colors: { ...appearance.colors, foreground: '#ffffff', accent: '#8ab4f8' } } }) }) : null }) : null;
|
|
398
|
+
const viewer = (state.file && (review || state.phase === 'viewing') || ['opening', 'failed'].includes(state.phase) && ['image', 'video', 'document'].includes(state.kind)) ? _jsx(MediaViewer, { showDelete: !review && enabled('delete'), showForward: !review && enabled('forward'), loading: state.phase === 'opening', expanded: expanded, onExpandedChange: setExpanded, keepControlsVisible: mediaViewer?.keepControlsVisible ?? appearance.mediaViewer?.keepControlsVisible, status: status, kind: state.kind, previewUri: state.previewUri, uri: state.file?.uri, title: review ? uiText('Preview attachment') : state.kind === 'image' ? uiText('Photo') : state.kind === 'video' ? uiText('Video') : state.kind === 'voice' ? uiText('Voice message') : uiText('File'), subtitle: state.file?.fileName, fileName: state.file?.fileName, byteSize: state.file?.byteSize, error: state.error ?? fileError, onClose: () => { setFileError(''); void controller.cancel(); }, reviewAction: review ? (state.phase === 'failed' ? 'Retry upload' : 'Add attachment') : undefined, onReview: review ? () => void controller.send() : undefined, downloading: downloading, transferProgress: downloading ? state.progress : undefined, onForward: actions?.onForward && enabled('forward') ? () => perform('forward', actions.onForward) : undefined, onDelete: actions?.onDelete && enabled('delete') ? () => perform('delete', actions.onDelete) : undefined, onDownload: !review && enabled('download') && ['image', 'video', 'document'].includes(state.kind) ? () => perform('download') : undefined, onShare: !review && enabled('share') ? () => perform('share') : undefined, children: !state.file ? null : state.kind === 'document' ? _jsx(ExpoDocumentPreview, { file: state.file, onOpenLink: onDocumentLink }) : state.kind === 'video' ? _jsx(VideoPlayer, { posterUri: state.previewUri, file: state.file, audio: audio, design: appearance }, state.file.uri) : state.kind === 'voice' ? _jsx(View, { style: { flex: 1, justifyContent: 'center', alignItems: 'center', padding: 20 }, children: _jsx(VoicePlayer, { file: state.file, audio: audio, design: { ...appearance, colors: { ...appearance.colors, foreground: '#ffffff', accent: '#8ab4f8' } } }) }) : null }) : null;
|
|
391
399
|
// Present immediately: an iOS fade can still be dismissing when another attachment
|
|
392
400
|
// opens, leaving the next native modal invisible. Safe area belongs to this window.
|
|
393
401
|
return _jsx(Modal, { transparent: true, visible: state.phase !== 'idle' && state.phase !== 'choosing', onDismiss: onDismiss, animationType: "none", onRequestClose: () => { if (expanded)
|
|
@@ -555,8 +563,8 @@ function ExpoMessagingScreenContent({ storage, audioSession, renderConversation,
|
|
|
555
563
|
return undefined;
|
|
556
564
|
const draft = m.media && m.kind !== 'text' && m.kind !== 'poll' ? await restore(m.media, m.kind) : undefined;
|
|
557
565
|
return draft ? copyMessagingCache(draft) : undefined;
|
|
558
|
-
});
|
|
559
|
-
}, [restore, controller]);
|
|
566
|
+
}, thumbnails.peek(m)?.uri);
|
|
567
|
+
}, [restore, controller, thumbnails]);
|
|
560
568
|
const screenProps = { ...props, requestedMessageAction,
|
|
561
569
|
onQuoteReady: props.onQuoteReady ?? defaultQuoteReady,
|
|
562
570
|
copyText: props.copyText ?? defaultCopyText,
|
|
@@ -573,7 +581,7 @@ function ExpoMessagingScreenContent({ storage, audioSession, renderConversation,
|
|
|
573
581
|
else {
|
|
574
582
|
message.current = null;
|
|
575
583
|
chosen.current = options.attachmentId;
|
|
576
|
-
media = !options.source && !options.attachmentId && options.intent !== 'preview' && ((options.maxCount ?? 1) > 1 || options.mixedLibrary) ? await controller.pickMany(kind, options.maxCount ?? 1, options.mixedLibrary) : await controller.pick(kind, options.source, options.
|
|
584
|
+
media = !options.source && !options.attachmentId && options.intent !== 'preview' && ((options.maxCount ?? 1) > 1 || options.mixedLibrary) ? await controller.pickMany(kind, options.maxCount ?? 1, options.mixedLibrary) : await controller.pick(kind, options.source, options.intent === 'preview' ? 'preview' : 'attach');
|
|
577
585
|
}
|
|
578
586
|
const selection = media ? (Array.isArray(media) ? media : [media]) : [];
|
|
579
587
|
try {
|
package/dist/expo-thumbnails.js
CHANGED
|
@@ -7,6 +7,7 @@ import * as FS from 'expo-file-system/legacy';
|
|
|
7
7
|
export function createExpoThumbnails(storage, local, remove) {
|
|
8
8
|
const cache = new MessagingPreviewCache();
|
|
9
9
|
const clear = () => cache.clear();
|
|
10
|
+
const keyFor = (message) => JSON.stringify([message.conversationId, message.media?.assetId, message.revision, message.media]);
|
|
10
11
|
function preview(message, options) {
|
|
11
12
|
const media = message.media;
|
|
12
13
|
if (!media || message.deleted)
|
|
@@ -15,7 +16,7 @@ export function createExpoThumbnails(storage, local, remove) {
|
|
|
15
16
|
return Promise.resolve({ waveform: media.waveform });
|
|
16
17
|
if (!['image', 'video'].includes(message.kind))
|
|
17
18
|
return Promise.resolve({});
|
|
18
|
-
const id = media.assetId, key =
|
|
19
|
+
const id = media.assetId, key = keyFor(message);
|
|
19
20
|
if (options?.refresh)
|
|
20
21
|
cache.invalidate(key);
|
|
21
22
|
return cache.get(key, async (signal) => {
|
|
@@ -57,5 +58,5 @@ export function createExpoThumbnails(storage, local, remove) {
|
|
|
57
58
|
});
|
|
58
59
|
}
|
|
59
60
|
// Uploaded IDs get their own authorized preview; never alias access between assets.
|
|
60
|
-
return { preview, clear };
|
|
61
|
+
return { preview, clear, peek: (message) => message.deleted ? undefined : cache.peek(keyFor(message)) };
|
|
61
62
|
}
|
package/dist/expo.d.ts
CHANGED
|
@@ -4,3 +4,4 @@ export { MessagingPopup } from './popup.js';
|
|
|
4
4
|
export { MessagingConnectionState, type MessagingConnectionStateProps, MessagingSignIn, MessagingPhoneInput, MessagingChoicePicker, type MessagingSignInProps, type MessagingPhoneInputProps, type MessagingChoice, type MessagingChoicePickerProps } from './sign-in.js';
|
|
5
5
|
export type { MessagingDirectoryContact, MessagingDirectoryOptions } from './contact-directory.js';
|
|
6
6
|
export { createExpoBridgeMessenger } from './expo-bridge.js';
|
|
7
|
+
export { configureExpoMessagingCache, maintainExpoMessagingCache, type MessagingDiskCacheLimits, type MessagingCacheMaintenanceResult } from './expo-cache.js';
|
package/dist/expo.js
CHANGED
|
@@ -3,3 +3,4 @@ export { ExpoMessenger, createExpoMessenger, createHostedExpoMessenger } from '.
|
|
|
3
3
|
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
|
+
export { configureExpoMessagingCache, maintainExpoMessagingCache } from './expo-cache.js';
|
package/dist/inbox.d.ts
CHANGED
|
@@ -19,8 +19,9 @@ export interface MessagingInboxProps extends MessagingDirectoryOptions {
|
|
|
19
19
|
searchText?: (conversation: ConversationSummary) => string;
|
|
20
20
|
appearance?: MessagingAppearance;
|
|
21
21
|
active?: boolean;
|
|
22
|
+
manageUpdates?: boolean;
|
|
22
23
|
onSelect: (conversation: ConversationSummary, messageId?: string) => void;
|
|
23
24
|
onDeleted?: (conversationId: string) => Promise<void> | void;
|
|
24
25
|
}
|
|
25
26
|
/** Compact Messenger chat rows: avatar, name, last message, time and unread badge. */
|
|
26
|
-
export declare function MessagingInbox({ client, userId, contacts, appearance, active, onSelect, onDeleted, companyName, headerActions, searchText, selectedId, query: controlledQuery, onSearchChange, viewMemory, directory, onOpenDirectoryContact }: MessagingInboxProps): React.JSX.Element;
|
|
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;
|
package/dist/inbox.js
CHANGED
|
@@ -14,14 +14,15 @@ import { AppState, FlatList, Image, Platform, Pressable, ScrollView, View } from
|
|
|
14
14
|
import { defaultMessagingSettings } from '@robono/messaging';
|
|
15
15
|
import { MessagingPopup, MessagingMenuSurface, MessagingPopupHeaderBoundary, useMessagingPopupColors, messagingPopupBackdrop } from './popup.js';
|
|
16
16
|
/** Compact Messenger chat rows: avatar, name, last message, time and unread badge. */
|
|
17
|
-
export function MessagingInbox({ client, userId, contacts = {}, appearance, active = true, onSelect, onDeleted, companyName, headerActions, searchText, selectedId, query: controlledQuery, onSearchChange, viewMemory, directory = [], onOpenDirectoryContact }) {
|
|
17
|
+
export function MessagingInbox({ client, userId, contacts = {}, appearance, active = true, manageUpdates = true, onSelect, onDeleted, companyName, headerActions, searchText, selectedId, query: controlledQuery, onSearchChange, viewMemory, directory = [], onOpenDirectoryContact }) {
|
|
18
18
|
const { text: uiText, locale: uiLocale, number: uiNumber, count: uiCount } = useRobonoLocale();
|
|
19
19
|
const state = useSyncExternalStore(client.subscribe, client.getSnapshot, client.getSnapshot), design = messagingScreenAppearance(appearance ?? state.appearance ?? defaultMessagingSettings().appearance), c = messagingFriendsColors(design), friends = design.screens?.friends;
|
|
20
20
|
const messagingPopupColors = useMessagingPopupColors(design, 'alerts');
|
|
21
|
-
useEffect(() => {
|
|
21
|
+
useEffect(() => { if (!manageUpdates)
|
|
22
|
+
return; const update = (value) => { if (active && (value === null || value === 'active'))
|
|
22
23
|
client.start();
|
|
23
24
|
else
|
|
24
|
-
client.stop(); }; update(AppState.currentState); const sub = AppState.addEventListener('change', update); return () => { sub.remove(); client.stop(); }; }, [client, active]);
|
|
25
|
+
client.stop(); }; update(AppState.currentState); const sub = AppState.addEventListener('change', update); return () => { sub.remove(); client.stop(); }; }, [client, active, manageUpdates]);
|
|
25
26
|
const ownMemory = useRef(createInboxViewMemory()), memory = viewMemory ?? ownMemory.current;
|
|
26
27
|
const [localQuery, setLocalQuery] = useState(memory.query);
|
|
27
28
|
const query = friends?.showSearch === false ? '' : controlledQuery ?? localQuery;
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { DeliveryBar } from './delivery-bar.js';
|
|
3
|
+
import { bubbleCorners, bubbleDelivery } from './bubble-design.js';
|
|
2
4
|
import { compareMessageOrder, isMessageIdentity } from '@robono/messaging';
|
|
3
5
|
import { messagingScreenAppearance } from '@robono/messaging';
|
|
4
6
|
import { messagingHeaderOrder } from '@robono/messaging';
|
|
@@ -30,7 +32,7 @@ import { AttachmentMenu } from './attachment-menu.js';
|
|
|
30
32
|
import { QuickSendButton } from './quick-send.js';
|
|
31
33
|
import { MessageExtra, MessagingPrivacyLayer, privacyReadingStripHeight, openChatAddress, ExtraPopup } from './extras.js';
|
|
32
34
|
export { MessagingPrivacyLayer } from './extras.js';
|
|
33
|
-
import { orderChatMessages
|
|
35
|
+
import { orderChatMessages } from './message-order.js';
|
|
34
36
|
import { MessagingPopup, MessagingPopupHost, MessagingPopupHeaderBoundary, useMessagingPopupColors } from './popup.js';
|
|
35
37
|
import { messageLinks } from './message-links.js';
|
|
36
38
|
import { MessagingForward } from './forward.js';
|
|
@@ -371,16 +373,11 @@ function MediaContent({ message, ink, footer, onOpen, onLongPress }) {
|
|
|
371
373
|
return Voice ? _jsx(Voice, { mine: message.senderId === userId, heard: heard, onPlayed: onPlayed, background: message.senderId === userId ? design.colors.outgoing : design.colors.incoming, message: message, ink: ink, accent: design.colors.accent, waveform: preview.waveform ?? message.media?.waveform, showWaveform: design.showWaveform !== false, footer: footer, onOpen: onOpen, onLongPress: onLongPress }) : _jsx(VoicePlayback, { mine: message.senderId === userId, heard: heard, onPlayed: onPlayed, background: message.senderId === userId ? design.colors.outgoing : design.colors.incoming, ink: ink, accent: design.colors.accent, waveform: preview.waveform ?? message.media?.waveform, showWaveform: design.showWaveform !== false, durationMs: message.media?.durationMs, footer: footer, onToggle: onOpen, onLongPress: onLongPress });
|
|
372
374
|
}
|
|
373
375
|
if (message.kind === 'image' || message.kind === 'video')
|
|
374
|
-
return _jsx(View, { style: { width: 220, maxWidth: '100%', gap: 0 }, children: _jsxs(View, { style: { height: 155,
|
|
375
|
-
return _jsxs(View, { testID: "file-message-content", style: { flexDirection: 'row', alignItems: 'center', gap: 10, width: 220, maxWidth: '100%', minHeight: 56, paddingHorizontal: 12, paddingVertical: 6,
|
|
376
|
+
return _jsx(View, { style: { width: 220, maxWidth: '100%', gap: 0 }, children: _jsxs(View, { testID: "media-bubble-surface", style: { height: 155, ...bubbleCorners(design, message.senderId === userId, !!message.text), overflow: 'hidden', alignItems: 'center', justifyContent: 'center', backgroundColor: '#00000012' }, children: [preview.uri ? _jsx(Image, { source: { uri: preview.uri }, accessibilityLabel: message.media?.fileName ?? uiText(mediaNames[message.kind]), resizeMode: "cover", onError: onImageError, style: { width: '100%', height: '100%' } }) : _jsx(MessageIcon, { name: message.kind, color: ink, size: 36 }), failed && !preview.uri && _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText('Retry preview'), onPress: event => { event.stopPropagation(); retry(); }, style: { position: 'absolute', bottom: 6, right: 6, minHeight: 44, paddingHorizontal: 12, justifyContent: 'center', backgroundColor: design.colors.incoming, borderRadius: 18 }, children: _jsx(Text, { style: { color: design.colors.accent }, children: uiText('Retry preview') }) }), message.kind === 'video' && _jsxs(_Fragment, { children: [_jsx(View, { style: { position: 'absolute', borderRadius: 24, padding: 10, backgroundColor: '#00000099' }, children: _jsx(MessageIcon, { name: "play", color: "#ffffff" }) }), _jsx(Text, { style: { position: 'absolute', left: 8, bottom: 8, color: '#ffffff', backgroundColor: '#000000aa', borderRadius: 4, paddingHorizontal: 5, fontSize: 12 }, children: duration(message.media?.durationMs) })] })] }) });
|
|
377
|
+
return _jsxs(View, { testID: "file-message-content", style: { flexDirection: 'row', alignItems: 'center', gap: 10, width: 220, maxWidth: '100%', minHeight: 56, paddingHorizontal: 12, paddingVertical: 6, ...bubbleCorners(design, message.senderId === userId), ...(message.senderId === userId && design.messageStatus?.style === 'circle' ? { paddingRight: 28 } : {}) }, children: [_jsx(MessageIcon, { name: "document", color: design.colors.accent, size: 24 }), _jsxs(View, { style: { flex: 1, gap: 2 }, children: [_jsx(Text, { numberOfLines: 2, style: { color: ink, fontSize: 14, fontWeight: '600' }, children: message.media?.fileName ?? uiText("File") }), _jsxs(Text, { style: { color: ink, fontSize: 12, opacity: 0.75 }, children: [message.media?.fileName?.split('.').pop()?.toUpperCase(), " \u00B7 ", fileSize(message.media?.byteSize)] })] })] });
|
|
376
378
|
}
|
|
377
379
|
function messageTimeLabel(message, format, text) { return (message.editedAt && !message.deleted ? text('edited') + ' · ' : '') + format(message.createdAt); }
|
|
378
|
-
function MessageMetadata({
|
|
379
|
-
const { text: uiText, locale: uiLocale, number: uiNumber, count: uiCount } = useRobonoLocale();
|
|
380
|
-
if (!mine || !pendingStatus)
|
|
381
|
-
return null;
|
|
382
|
-
return _jsx(View, { accessibilityLabel: pendingStatus === 'queued' ? uiText("Waiting for connection") : pendingStatus === 'sending' ? uiText("Sending message") : uiText("Message not sent"), style: { alignSelf: 'flex-end' }, children: _jsx(MessageIcon, { name: pendingStatus === 'failed' ? 'warning' : 'clock', color: pendingStatus === 'failed' ? '#c94040' : ink, size: 15 }) });
|
|
383
|
-
}
|
|
380
|
+
function MessageMetadata(_props) { return null; }
|
|
384
381
|
/** Keep the heavy row independent of unrelated draft, connection and message updates.
|
|
385
382
|
* Every permission, appearance, host callback and referenced message is selected
|
|
386
383
|
* afresh; no access decision or host callback is cached across a change. */
|
|
@@ -410,9 +407,9 @@ export function MessagingBubble(props) {
|
|
|
410
407
|
const context = useMessagingUI(), last = useRef(null);
|
|
411
408
|
const selected = selectBubbleUI(context, props, last.current);
|
|
412
409
|
last.current = selected;
|
|
413
|
-
return _jsx(MessagingBubbleView, { message: props.message, pendingStatus: props.pendingStatus,
|
|
410
|
+
return _jsx(MessagingBubbleView, { message: props.message, pendingStatus: props.pendingStatus, ui: selected });
|
|
414
411
|
}
|
|
415
|
-
const MessagingBubbleView = React.memo(function MessagingBubbleView({ message, pendingStatus,
|
|
412
|
+
const MessagingBubbleView = React.memo(function MessagingBubbleView({ message, pendingStatus, ui }) {
|
|
416
413
|
const messagingPopupColors = useMessagingPopupColors(undefined, 'alerts');
|
|
417
414
|
const { text: uiText, locale: uiLocale, number: uiNumber, count: uiCount } = useRobonoLocale();
|
|
418
415
|
const { userId, design, state, client, participants, openDiscussion, discussionPreview, discussionRoot, setReply, setEditing, setForwarding, setDeleting, selectionActive, setSelection, saved, saving, toggleSaved, onMessageOptions, openAttachment, language, contact, copyText, components, extras, onCallHistory, linkHandling, languageTools } = ui;
|
|
@@ -424,7 +421,9 @@ const MessagingBubbleView = React.memo(function MessagingBubbleView({ message, p
|
|
|
424
421
|
const socialReady = linkHandling?.webLinks !== false && !linkHandling?.openUrl && !message.custom && !extra?.address && !pendingStatus && !message.deleted && message.kind === 'text' && state.settings?.enabled && state.socialPreviewAvailable && components?.SocialPlayer && messageLinks(message.text ?? '').some(link => !!link.url && !!socialShare(link.url, socialOrigin));
|
|
425
422
|
const contextContactName = contact.name;
|
|
426
423
|
const mine = message.senderId === userId, c = design.colors, ink = message.kind === 'poll' ? c.foreground : mine ? c.outgoingText : c.incomingText;
|
|
427
|
-
const
|
|
424
|
+
const corners = bubbleCorners(design, mine), bubbleRadius = corners.borderTopRightRadius;
|
|
425
|
+
const status = bubbleDelivery(message, deliveryStatus, !!state.settings?.features.readReceipts, design);
|
|
426
|
+
const circleStatus = mine && status.style === 'circle';
|
|
428
427
|
const messageGap = design.presentation?.messageSpacing === 'compact' ? 4 : design.presentation?.messageSpacing === 'relaxed' ? 12 : 8;
|
|
429
428
|
const visual = message.kind === 'image' || message.kind === 'video', voice = message.kind === 'voice';
|
|
430
429
|
const grouped = ui.grouped;
|
|
@@ -522,18 +521,20 @@ const MessagingBubbleView = React.memo(function MessagingBubbleView({ message, p
|
|
|
522
521
|
const showingTransform = !!transformed && !showOriginal && (transformed.kind === 'transcript' || canTranslate);
|
|
523
522
|
const languageActions = (canTranscript || canTranslate || transformed) && _jsxs(View, { testID: "message-language-actions", style: { flexDirection: 'row', flexWrap: 'wrap', justifyContent: voice && !showingTransform ? 'flex-end' : 'flex-start', columnGap: 8, rowGap: 0 }, children: [transforming && _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText("Cancel"), onPress: () => { transformAbort.current?.abort(); transformGeneration.current++; setTransforming(false); }, hitSlop: 8, children: _jsx(Text, { style: { color: c.accent, fontSize: 11, lineHeight: 15 }, children: uiText("Cancel") }) }), transformed && _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: showOriginal ? (transformed.kind === 'transcript' ? 'Show transcript' : 'Show translation') : uiText("Show original"), onPress: () => { setTranslationAutoPlay(false); setShowOriginal(v => !v); }, hitSlop: 8, style: { minHeight: 17, paddingVertical: 1, justifyContent: 'center' }, children: _jsx(Text, { style: { color: c.accent, fontSize: 11, lineHeight: 15 }, children: showOriginal ? (transformed.kind === 'transcript' ? 'Show transcript' : 'Show translation') : uiText("Show original") }) }), canTranscript && !transformed && _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText("Read transcript"), disabled: transforming, onPress: () => void transform('transcript'), hitSlop: 8, style: { minHeight: 17, paddingVertical: 1, justifyContent: 'center' }, children: _jsx(Text, { style: { color: c.accent, fontSize: 11, lineHeight: 15 }, children: transforming ? uiText("Transcribing…") : uiText("Transcript") }) }), canTranslate && transformed?.kind !== 'translation' && _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: translation.mode === 'voice' && languageTools?.voiceOutput !== false ? uiText("Play translation") : uiText("Translate message"), disabled: transforming, onPress: () => void transform('translation', translation.mode === 'voice' && languageTools?.voiceOutput !== false ? 'voice' : 'text'), hitSlop: 8, style: { minHeight: 17, paddingVertical: 1, justifyContent: 'center' }, children: _jsx(Text, { style: { color: c.accent, fontSize: 11, lineHeight: 15 }, children: translation.mode === 'voice' && languageTools?.voiceOutput !== false ? uiText("Play Translation") : uiText("Translate") }) })] });
|
|
524
523
|
const fallbackContent = _jsx(View, { testID: "message-original-text", children: _jsx(Text, { selectable: true, style: { color: ink, fontSize: 16, lineHeight: 22 }, children: renderText(message.text ?? '') }) });
|
|
525
|
-
const originalContent = message.custom && !message.deleted ? _jsxs(Pressable, { onLongPress: menu, children: [_jsx(CustomMessage, { message: message, mine: mine, appearance: design, pendingStatus: pendingStatus, components: components, enabled: canInteract, children: fallbackContent }), pendingStatus && footer] }) : extra?.weather || extra?.call ? extraCard : message.kind === 'poll' ? _jsx(PollMessage, { onLongPress: menu, message: message, userId: userId, ink: ink, accent: c.accent, background: c.background, foreground: c.foreground, resolveVoterName: id => id === userId ? 'You' : participants?.[id]?.name ?? (state.conversation?.kind === 'direct' ? contextContactName : 'Chat member'), enabled: canInteract && !!state.settings?.features.poll, onVote: options => client.vote(message.id, options), onClose: () => client.closePoll(message.id) }) : message.kind === 'text' ? _jsxs(View, { testID: "message-original-text", children: [_jsx(Text, { selectable: true, style: { color: ink, fontSize: bigEmoji ? 48 : 16, lineHeight: bigEmoji ? 58 : 22 }, children: renderText(message.text ?? '') }), pendingStatus && footer] }) : _jsx(MediaContent, { message: message, ink: ink, accent: c.accent, footer: voice ? languageActions : undefined, onOpen: () => void open(), onLongPress: menu });
|
|
526
|
-
const content = showingTransform ? _jsxs(View, { children: [_jsx(Text, { style: { color: ink, fontSize: 11, opacity: .65, marginBottom: 2 }, children: transformed.kind === 'transcript' ? uiText("Transcript") : 'Translated · ' + supportedLanguageLabel(translationLanguage) }), transformed.audio && TranslationVoice ? _jsx(View, { testID: "message-translated-voice", children: _jsx(TranslationVoice, { transform: transformed, ink: ink, accent: c.accent, showWaveform: design.showWaveform !== false, autoPlay: translationAutoPlay }) }) : _jsx(Text, { testID: "message-language-result", selectable: true, style: { color: ink, fontSize: 16, lineHeight: 22 }, children: transformed.text }), !voice && footer] }) : originalContent;
|
|
524
|
+
const originalContent = message.custom && !message.deleted ? _jsxs(Pressable, { onLongPress: menu, children: [_jsx(CustomMessage, { message: message, mine: mine, appearance: design, pendingStatus: pendingStatus, components: components, enabled: canInteract, children: fallbackContent }), pendingStatus && footer] }) : extra?.weather || extra?.call ? extraCard : message.kind === 'poll' ? _jsx(PollMessage, { onLongPress: menu, message: message, userId: userId, ink: ink, accent: c.accent, background: c.background, foreground: c.foreground, resolveVoterName: id => id === userId ? 'You' : participants?.[id]?.name ?? (state.conversation?.kind === 'direct' ? contextContactName : 'Chat member'), enabled: canInteract && !!state.settings?.features.poll, onVote: options => client.vote(message.id, options), onClose: () => client.closePoll(message.id) }) : message.kind === 'text' ? _jsxs(View, { testID: "message-original-text", children: [_jsx(Text, { selectable: true, style: { color: ink, fontSize: bigEmoji ? 48 : 16, lineHeight: bigEmoji ? 58 : 22, textAlign: mine ? 'right' : 'left' }, children: renderText(message.text ?? '') }), pendingStatus && footer] }) : _jsx(MediaContent, { message: message, ink: ink, accent: c.accent, footer: voice ? languageActions : undefined, onOpen: () => void open(), onLongPress: menu });
|
|
525
|
+
const content = showingTransform ? _jsxs(View, { children: [_jsx(Text, { style: { color: ink, fontSize: 11, opacity: .65, marginBottom: 2 }, children: transformed.kind === 'transcript' ? uiText("Transcript") : 'Translated · ' + supportedLanguageLabel(translationLanguage) }), transformed.audio && TranslationVoice ? _jsx(View, { testID: "message-translated-voice", children: _jsx(TranslationVoice, { transform: transformed, ink: ink, accent: c.accent, showWaveform: design.showWaveform !== false, autoPlay: translationAutoPlay }) }) : _jsx(Text, { testID: "message-language-result", selectable: true, style: { color: ink, fontSize: 16, lineHeight: 22, textAlign: mine ? 'right' : 'left' }, children: transformed.text }), !voice && footer] }) : originalContent;
|
|
527
526
|
const regionProps = { message, mine, appearance: design, pendingStatus };
|
|
528
527
|
const bodyContent = components?.MessageBody && !message.deleted ? _jsx(components.MessageBody, { ...regionProps, children: content }) : content;
|
|
529
|
-
const
|
|
528
|
+
const statusTopRadius = voice && !showingTransform ? 24 : design.presentation?.bubbleStyle === 'top-tail' && !visual ? 0 : bubbleRadius, statusBottomRadius = voice && !message.text && !showingTransform ? 24 : corners.borderBottomRightRadius;
|
|
529
|
+
// Cover the full inside edge; each curved end tapers to the bubble's corner.
|
|
530
|
+
const bubbleBody = _jsxs(_Fragment, { children: [mine && _jsx(View, { testID: 'message-status-' + status.phase, pointerEvents: "none", accessibilityLabel: uiText(status.phase === 'failed' ? 'Message not sent' : status.phase === 'sent' ? 'Sending message' : status.phase === 'consumed' ? (voice ? 'Heard' : message.kind === 'video' ? 'Watched' : 'Seen') : 'Delivered'), style: circleStatus ? { position: 'absolute', bottom: 5, end: 5, zIndex: 40, width: 17, height: 17, borderRadius: 9, borderWidth: 1.5, borderColor: status.color, backgroundColor: status.phase === 'consumed' ? status.color : '#00000055', alignItems: 'center', justifyContent: 'center' } : { position: 'absolute', top: 0, bottom: 0, end: 0, width: Math.max(statusTopRadius, statusBottomRadius) + 2, zIndex: 40, overflow: 'hidden' }, children: circleStatus ? (status.phase !== 'sent' && _jsx(MessageIcon, { name: status.phase === 'failed' ? 'warning' : 'check', color: status.phase === 'consumed' ? (parseInt(status.color.slice(1, 3), 16) * .299 + parseInt(status.color.slice(3, 5), 16) * .587 + parseInt(status.color.slice(5, 7), 16) * .114 > 150 ? '#111111' : '#ffffff') : status.color, size: 12 })) : _jsx(DeliveryBar, { color: status.color, topRadius: statusTopRadius, bottomRadius: statusBottomRadius }) }), message.replyTo && message.replyTo !== discussionRoot && _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText("Go to quoted message"), onLongPress: menu, onPress: () => { void client.focusMessage(message.replyTo).catch(e => setError(e instanceof Error ? e.message : uiText("This message is unavailable."))); }, style: { alignSelf: 'flex-start', maxWidth: 220, minHeight: 44, borderRadius: 10, backgroundColor: chatSurface(c.background) === '#ffffff' ? '#f3f3f3' : '#242424', borderWidth: StyleSheet.hairlineWidth, borderColor: c.secondary + '55', paddingHorizontal: 8, paddingTop: 6, paddingBottom: 7, marginBottom: 4, overflow: 'hidden' }, children: _jsx(QuotedPreview, { message: ui.quoted, ink: c.foreground }) }), !mine && !grouped && state.conversation?.kind === 'group' && _jsx(Text, { style: { color: ink, fontSize: 12, fontWeight: '600', marginBottom: 5 }, children: message.deleted ? uiText("Former member") : participants?.[message.senderId]?.name ?? uiText("Member") }), message.custom || extra?.address || extra?.weather || extra?.call || voice || message.kind === 'poll' ? bodyContent : _jsx(Pressable, { accessibilityRole: message.kind === 'text' ? undefined : 'button', accessibilityLabel: message.kind === 'text' ? undefined : uiText('{kind}: {name}', { kind: uiText(mediaNames[message.kind]), name: message.media?.fileName ?? uiText('Open attachment') }), disabled: busy, onLongPress: menu, onPress: message.kind === 'text' ? () => { if (quoteGesture.suppressPress())
|
|
530
531
|
return; if (extra?.address)
|
|
531
532
|
extraRef.current?.open();
|
|
532
533
|
else
|
|
533
|
-
socialRef.current?.open(); } : () => void open(), children: bodyContent }), !discussionPreview && state.discussionAvailable && !!message.replyCount && _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: message.replyCount + ' ' + (message.replyCount === 1 ? 'reply' : 'replies'), onPress: () => openDiscussion(message.id), style: { minHeight: 32, justifyContent: 'center' }, children: _jsxs(Text, { style: { color: c.accent, fontSize: 12, fontWeight: '600' }, children: [message.replyCount, " ", message.replyCount === 1 ? uiText("reply") : uiText("replies")] }) }), message.kind !== 'text' && !!message.text && _jsx(Text, { testID: "attachment-caption", selectable: true, onLongPress: menu, style: { color: ink, fontSize: 16, lineHeight: 22, marginTop: 2, textAlign: 'right', alignSelf: 'stretch', paddingHorizontal: voice || message.kind === 'document' ? 8 : 2, paddingBottom: 2 }, children: renderText(message.text) }), deliveryStatus && message.kind !== 'text' && message.kind !== 'poll' && !voice && !visual && _jsx(View, { style: { marginTop: 4, alignSelf: 'flex-end' }, children: footer }), (!voice || showingTransform) && languageActions, components?.MessageFooter && !message.deleted && _jsx(components.MessageFooter, { ...regionProps }), transforming && !voice && _jsx(Text, { accessibilityLiveRegion: "polite", style: { color: ink, fontSize: 11 }, children: uiText("Converting…") }), !!error && _jsxs(MessagingPopup, { screen: "alerts", compact: true, contentWidth: 640, title: uiText("Message"), foreground: c.foreground, background: chatSurface(c.background), onClose: () => setError(''), children: [_jsx(Text, { accessibilityRole: "alert", style: { color: messagingPopupColors.foreground, fontSize: 15, lineHeight: 21, marginTop: 8 }, children: error }), _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText("Close message alert"), onPress: () => setError(''), style: { alignSelf: 'flex-end', minHeight: 44, justifyContent: 'center', paddingHorizontal: 8, marginTop: 8 }, children: _jsx(Text, { style: { color: c.accent }, children: uiText("OK") }) })] }), deliveryStatus === 'failed' && _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText("Retry sending message"), onPress: () => void client.retry(message.clientMessageId).catch(() => { }), style: { minHeight: 32, justifyContent: 'center', alignSelf: 'flex-end' }, children: _jsx(Text, { style: { color: c.accent, fontSize: 12 }, children: design.labels.retry }) }), Platform.OS === 'web' && !mine && canInteract && state.settings?.features.reactions && _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText("React to message"), onFocus: () => setHovered(true), onBlur: () => setHovered(false), onPress: openMenu, style: { opacity: hovered || actions ? 1 : 0, position: 'absolute', top: 6, ...(mine ? { left: -34 } : { right: -34 }), width: 32, height: 32, alignItems: 'center', justifyContent: 'center' }, children: _jsx(MessageIcon, { name: "reaction", color: c.secondary, size: 20 }) }), !!message.reactions?.length && _jsx(View, { testID: "message-reaction-badge", pointerEvents: "none", accessibilityLabel: message.reactions.slice(-3).map(r => r.emoji).join(' '), style: { position: 'absolute', zIndex: 41, top: -16, ...(mine ? { end: -9 } : { start: -9 }), minWidth: 30, height: 20, alignItems: 'center', justifyContent: 'center' }, children: _jsx(Text, { style: { fontSize: 16, lineHeight: 20 }, children: message.reactions.slice(-3).map(r => r.emoji).join(' ') }) }), _jsx(MessageMenu, { visible: actions, position: menuPosition, screenHeight: viewport.height, mine: mine, reactions: reactionPicker, onClose: () => setActions(false), onDismiss: menuDismissed, children: actions && _jsxs(_Fragment, { children: [quoting && _jsx(MessageMenuRow, { icon: "quote", label: uiText("Quote message"), onPress: () => { setActions(false); setReply(message); } }), !discussionPreview && state.discussionAvailable && !pendingStatus && !message.deleted && _jsx(MessageMenuRow, { icon: "quote", label: uiText("Replies"), onPress: () => leaveMenu(() => openDiscussion(message.threadRoot ?? message.id)) }), state.discussionAvailable && canInteract && state.conversation?.ownerId === userId && _jsx(MessageMenuRow, { icon: "bookmark", label: message.pinned ? uiText("Unpin for group") : uiText("Pin for group"), onPress: () => { setActions(false); void client.pinMessage(message.id, !message.pinned).catch(e => setError(e instanceof Error ? e.message : uiText("The pin could not change."))); } }), canCopy && _jsx(MessageMenuRow, { icon: "copy", label: uiText("Copy"), onPress: () => { setActions(false); void (copyText ? copyText(message.text) : navigator.clipboard.writeText(message.text)).catch(() => setError(uiText("The text could not be copied."))); } }), canInteract && client.canForward(message) && _jsx(MessageMenuRow, { icon: "redo", label: uiText("Forward"), onPress: () => leaveMenu(() => setForwarding([message])) }), !pendingStatus && !message.deleted && message.kind !== 'poll' && client.hasSavedMessages() && _jsx(MessageMenuRow, { icon: "bookmark", label: saved.some(r => r.key === savedMessageKey(message)) ? uiText("Remove from Saved") : uiText("Save"), disabled: saving, onPress: () => { setActions(false); void toggleSaved(message); } }), canChange && !message.custom && message.kind !== 'poll' && state.settings?.features[message.kind] && _jsx(MessageMenuRow, { icon: "edit", label: uiText("Edit"), onPress: () => { setActions(false); setEditing(message); } }), !mine && state.conversation?.safety?.canReport && _jsx(MessageMenuRow, { icon: "flag", label: uiText("Report"), danger: true, onPress: () => leaveMenu(() => setReportOpen(true)) }), !pendingStatus && !message.deleted && ['owner', 'moderator'].includes(state.conversation?.roomRole ?? '') && _jsx(MessageMenuRow, { icon: "trash", label: uiText('Remove from group'), danger: true, onPress: () => leaveMenu(() => setRoomRemoval(true)) }), canChange && _jsx(MessageMenuRow, { icon: "trash", label: uiText("Delete"), danger: true, onPress: () => leaveMenu(() => setDeleting([message])) }), (pendingStatus === 'failed' || pendingStatus === 'queued') && _jsx(MessageMenuRow, { icon: "trash", label: uiText("Remove unsent message"), danger: true, onPress: () => { setActions(false); void client.discardPending(message.clientMessageId).catch(() => setError(uiText("The unsent message could not be removed."))); } }), !pendingStatus && onMessageOptions && _jsx(MessageMenuRow, { icon: "more", label: uiText("More options"), onPress: () => leaveMenu(() => onMessageOptions(message)) }), !pendingStatus && !message.deleted && _jsx(MessageMenuRow, { icon: "check", label: uiText("Select Multiple"), divider: true, onPress: () => { setActions(false); setSelection([message]); Keyboard.dismiss(); } })] }) }), roomRemoval && _jsx(MessagingRoomRemoval, { client: client, message: message, accent: c.accent, onClose: () => setRoomRemoval(false) }), reportOpen && _jsx(MessagingSafety, { client: client, state: state, appearance: design, name: participants?.[message.senderId]?.name ?? 'Contact', messageId: message.id, onClose: () => setReportOpen(false) })] });
|
|
534
|
-
return _jsxs(View, { ...(Platform.OS === 'web' ? { onMouseEnter: () => setHovered(true), onMouseLeave: () => setHovered(false), onContextMenu: (event) => { event.preventDefault(); menu(); } } : {}), style: { width: '100%', position: 'relative', marginTop: messageGap + (message.reactions?.length ? 16 : 0), marginBottom: 0 }, children: [quoteGesture.infoLoaded && _jsxs(Animated.View, { pointerEvents: "none", testID: "message-info-reveal", accessible: false, accessibilityElementsHidden: true, importantForAccessibility: "no-hide-descendants", style: { ...quoteGesture.revealWebStyle, position: 'absolute', top: '50%', marginTop: -26, minHeight: 52, width: messageInfoRevealWidth, justifyContent: 'center', ...(mine ? { start: 0, alignItems: 'flex-start' } : { end: 0, alignItems: 'flex-end' }), opacity: quoteGesture.infoOpacity }, children: [_jsxs(View, { style: { flexDirection: 'row', alignItems: 'baseline', gap: 4 }, children: [_jsx(Text, { style: { color: c.secondary, fontSize: 8, lineHeight: 11, fontWeight: '900' }, children: uiText("SENT:") }), _jsx(Text, { style: { color: c.foreground, fontSize: 10, lineHeight: 12, fontWeight: '800' }, children: messageTimeLabel(message, ui.formatMessageTime, uiText) })] }), mine && state.settings?.features.readReceipts && _jsxs(View, { style: { flexDirection: 'row', alignItems: 'baseline', gap: 4 }, children: [_jsx(Text, { style: { color: c.secondary, fontSize: 8, lineHeight: 11, fontWeight: '900' }, children: uiText("READ:") }), _jsx(Text, { style: { color: message.readAt ? c.foreground : c.secondary, fontSize: 10, lineHeight: 12, fontWeight: '800' }, children: message.readAt ? ui.formatMessageTime(message.readAt) : uiText("Not yet") })] })] }), quoting && _jsxs(Animated.View, { pointerEvents: "none", ...(Platform.OS === 'web' ? { 'aria-hidden': true } : { accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants' }), testID: `quote-reveal-${mine ? 'outgoing' : 'incoming'}`, style: { ...quoteGesture.revealWebStyle, position: 'absolute', top: '50%', marginTop: -26, ...(mine ? { end: 0 } : { start: 0 }), width: messageReplyRevealWidth, minHeight: 52, gap: 3, alignItems: 'center', justifyContent: 'center', opacity: quoteGesture.revealOpacity }, children: [_jsx(View, { style: { width: 40, height: 40, borderRadius: 20, alignItems: 'center', justifyContent: 'center', backgroundColor: chatSurface(c.background), borderWidth: 1.5, borderColor: c.secondary + '40' }, children: _jsx(MessageIcon, { name: "quote", color: c.accent, size: 30 }) }), _jsx(Text, { style: { color: c.secondary, fontSize: 10, fontWeight: '900' }, children: uiText("QUOTE MESSAGE") })] }),
|
|
534
|
+
socialRef.current?.open(); } : () => void open(), children: bodyContent }), !discussionPreview && state.discussionAvailable && !!message.replyCount && _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: message.replyCount + ' ' + (message.replyCount === 1 ? 'reply' : 'replies'), onPress: () => openDiscussion(message.id), style: { minHeight: 32, justifyContent: 'center' }, children: _jsxs(Text, { style: { color: c.accent, fontSize: 12, fontWeight: '600' }, children: [message.replyCount, " ", message.replyCount === 1 ? uiText("reply") : uiText("replies")] }) }), message.kind !== 'text' && !!message.text && _jsx(View, { testID: voice ? 'voice-message-caption' : undefined, style: voice && !showingTransform ? { maxWidth: 220, alignSelf: mine ? 'flex-end' : 'flex-start', marginTop: 1, paddingTop: 4, paddingBottom: 1, borderRadius: 14, ...(mine ? { borderBottomEndRadius: 3 } : { borderBottomStartRadius: 3 }), backgroundColor: mine ? c.outgoing : c.incoming } : visual ? { backgroundColor: mine ? c.outgoing : c.incoming, ...corners, borderTopLeftRadius: 0, borderTopRightRadius: 0, paddingHorizontal: 6, paddingVertical: 3, ...(circleStatus ? { paddingEnd: 24 } : {}) } : undefined, children: _jsx(Text, { testID: "attachment-caption", selectable: true, onLongPress: menu, style: { color: ink, fontSize: 16, lineHeight: 22, marginTop: voice ? 0 : 2, textAlign: mine ? 'right' : 'left', alignSelf: 'stretch', paddingHorizontal: voice || message.kind === 'document' ? 8 : 2, paddingBottom: 2 }, children: renderText(message.text) }) }), deliveryStatus && message.kind !== 'text' && message.kind !== 'poll' && !voice && !visual && _jsx(View, { style: { marginTop: 4, alignSelf: 'flex-end' }, children: footer }), (!voice || showingTransform) && languageActions, components?.MessageFooter && !message.deleted && _jsx(components.MessageFooter, { ...regionProps }), transforming && !voice && _jsx(Text, { accessibilityLiveRegion: "polite", style: { color: ink, fontSize: 11 }, children: uiText("Converting…") }), !!error && _jsxs(MessagingPopup, { screen: "alerts", compact: true, contentWidth: 640, title: uiText("Message"), foreground: c.foreground, background: chatSurface(c.background), onClose: () => setError(''), children: [_jsx(Text, { accessibilityRole: "alert", style: { color: messagingPopupColors.foreground, fontSize: 15, lineHeight: 21, marginTop: 8 }, children: error }), _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText("Close message alert"), onPress: () => setError(''), style: { alignSelf: 'flex-end', minHeight: 44, justifyContent: 'center', paddingHorizontal: 8, marginTop: 8 }, children: _jsx(Text, { style: { color: c.accent }, children: uiText("OK") }) })] }), deliveryStatus === 'failed' && _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText("Retry sending message"), onPress: () => void client.retry(message.clientMessageId).catch(() => { }), style: { minHeight: 32, justifyContent: 'center', alignSelf: 'flex-end' }, children: _jsx(Text, { style: { color: c.accent, fontSize: 12 }, children: design.labels.retry }) }), Platform.OS === 'web' && !mine && canInteract && state.settings?.features.reactions && _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText("React to message"), onFocus: () => setHovered(true), onBlur: () => setHovered(false), onPress: openMenu, style: { opacity: hovered || actions ? 1 : 0, position: 'absolute', top: 6, ...(mine ? { left: -34 } : { right: -34 }), width: 32, height: 32, alignItems: 'center', justifyContent: 'center' }, children: _jsx(MessageIcon, { name: "reaction", color: c.secondary, size: 20 }) }), !!message.reactions?.length && _jsx(View, { testID: "message-reaction-badge", pointerEvents: "none", accessibilityLabel: message.reactions.slice(-3).map(r => r.emoji).join(' '), style: { position: 'absolute', zIndex: 41, top: -16, ...(mine ? { end: -9 } : { start: -9 }), minWidth: 30, height: 20, alignItems: 'center', justifyContent: 'center' }, children: _jsx(Text, { style: { fontSize: 16, lineHeight: 20 }, children: message.reactions.slice(-3).map(r => r.emoji).join(' ') }) }), _jsx(MessageMenu, { visible: actions, position: menuPosition, screenHeight: viewport.height, mine: mine, reactions: reactionPicker, onClose: () => setActions(false), onDismiss: menuDismissed, children: actions && _jsxs(_Fragment, { children: [quoting && _jsx(MessageMenuRow, { icon: "quote", label: uiText("Quote message"), onPress: () => { setActions(false); setReply(message); } }), !discussionPreview && state.discussionAvailable && !pendingStatus && !message.deleted && _jsx(MessageMenuRow, { icon: "quote", label: uiText("Replies"), onPress: () => leaveMenu(() => openDiscussion(message.threadRoot ?? message.id)) }), state.discussionAvailable && canInteract && state.conversation?.ownerId === userId && _jsx(MessageMenuRow, { icon: "bookmark", label: message.pinned ? uiText("Unpin for group") : uiText("Pin for group"), onPress: () => { setActions(false); void client.pinMessage(message.id, !message.pinned).catch(e => setError(e instanceof Error ? e.message : uiText("The pin could not change."))); } }), canCopy && _jsx(MessageMenuRow, { icon: "copy", label: uiText("Copy"), onPress: () => { setActions(false); void (copyText ? copyText(message.text) : navigator.clipboard.writeText(message.text)).catch(() => setError(uiText("The text could not be copied."))); } }), canInteract && client.canForward(message) && _jsx(MessageMenuRow, { icon: "redo", label: uiText("Forward"), onPress: () => leaveMenu(() => setForwarding([message])) }), !pendingStatus && !message.deleted && message.kind !== 'poll' && client.hasSavedMessages() && _jsx(MessageMenuRow, { icon: "bookmark", label: saved.some(r => r.key === savedMessageKey(message)) ? uiText("Remove from Saved") : uiText("Save"), disabled: saving, onPress: () => { setActions(false); void toggleSaved(message); } }), canChange && !message.custom && message.kind !== 'poll' && state.settings?.features[message.kind] && _jsx(MessageMenuRow, { icon: "edit", label: uiText("Edit"), onPress: () => { setActions(false); setEditing(message); } }), !mine && state.conversation?.safety?.canReport && _jsx(MessageMenuRow, { icon: "flag", label: uiText("Report"), danger: true, onPress: () => leaveMenu(() => setReportOpen(true)) }), !pendingStatus && !message.deleted && ['owner', 'moderator'].includes(state.conversation?.roomRole ?? '') && _jsx(MessageMenuRow, { icon: "trash", label: uiText('Remove from group'), danger: true, onPress: () => leaveMenu(() => setRoomRemoval(true)) }), canChange && _jsx(MessageMenuRow, { icon: "trash", label: uiText("Delete"), danger: true, onPress: () => leaveMenu(() => setDeleting([message])) }), (pendingStatus === 'failed' || pendingStatus === 'queued') && _jsx(MessageMenuRow, { icon: "trash", label: uiText("Remove unsent message"), danger: true, onPress: () => { setActions(false); void client.discardPending(message.clientMessageId).catch(() => setError(uiText("The unsent message could not be removed."))); } }), !pendingStatus && onMessageOptions && _jsx(MessageMenuRow, { icon: "more", label: uiText("More options"), onPress: () => leaveMenu(() => onMessageOptions(message)) }), !pendingStatus && !message.deleted && _jsx(MessageMenuRow, { icon: "check", label: uiText("Select Multiple"), divider: true, onPress: () => { setActions(false); setSelection([message]); Keyboard.dismiss(); } })] }) }), roomRemoval && _jsx(MessagingRoomRemoval, { client: client, message: message, accent: c.accent, onClose: () => setRoomRemoval(false) }), reportOpen && _jsx(MessagingSafety, { client: client, state: state, appearance: design, name: participants?.[message.senderId]?.name ?? 'Contact', messageId: message.id, onClose: () => setReportOpen(false) })] });
|
|
535
|
+
return _jsxs(View, { ...(Platform.OS === 'web' ? { onMouseEnter: () => setHovered(true), onMouseLeave: () => setHovered(false), onContextMenu: (event) => { event.preventDefault(); menu(); } } : {}), style: { width: '100%', position: 'relative', marginTop: messageGap + (message.reactions?.length ? 16 : 0), marginBottom: 0 }, children: [quoteGesture.infoLoaded && _jsxs(Animated.View, { pointerEvents: "none", testID: "message-info-reveal", accessible: false, accessibilityElementsHidden: true, importantForAccessibility: "no-hide-descendants", style: { ...quoteGesture.revealWebStyle, position: 'absolute', top: '50%', marginTop: -26, minHeight: 52, width: messageInfoRevealWidth, justifyContent: 'center', ...(mine ? { start: 0, alignItems: 'flex-start' } : { end: 0, alignItems: 'flex-end' }), opacity: quoteGesture.infoOpacity }, children: [_jsxs(View, { style: { flexDirection: 'row', alignItems: 'baseline', gap: 4 }, children: [_jsx(Text, { style: { color: c.secondary, fontSize: 8, lineHeight: 11, fontWeight: '900' }, children: uiText("SENT:") }), _jsx(Text, { style: { color: c.foreground, fontSize: 10, lineHeight: 12, fontWeight: '800' }, children: messageTimeLabel(message, ui.formatMessageTime, uiText) })] }), mine && state.settings?.features.readReceipts && _jsxs(View, { style: { flexDirection: 'row', alignItems: 'baseline', gap: 4 }, children: [_jsx(Text, { style: { color: c.secondary, fontSize: 8, lineHeight: 11, fontWeight: '900' }, children: uiText("READ:") }), _jsx(Text, { style: { color: message.readAt ? c.foreground : c.secondary, fontSize: 10, lineHeight: 12, fontWeight: '800' }, children: message.readAt ? ui.formatMessageTime(message.readAt) : uiText("Not yet") })] })] }), quoting && _jsxs(Animated.View, { pointerEvents: "none", ...(Platform.OS === 'web' ? { 'aria-hidden': true } : { accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants' }), testID: `quote-reveal-${mine ? 'outgoing' : 'incoming'}`, style: { ...quoteGesture.revealWebStyle, position: 'absolute', top: '50%', marginTop: -26, ...(mine ? { end: 0 } : { start: 0 }), width: messageReplyRevealWidth, minHeight: 52, gap: 3, alignItems: 'center', justifyContent: 'center', opacity: quoteGesture.revealOpacity }, children: [_jsx(View, { style: { width: 40, height: 40, borderRadius: 20, alignItems: 'center', justifyContent: 'center', backgroundColor: chatSurface(c.background), borderWidth: 1.5, borderColor: c.secondary + '40' }, children: _jsx(MessageIcon, { name: "quote", color: c.accent, size: 30 }) }), _jsx(Text, { style: { color: c.secondary, fontSize: 10, fontWeight: '900' }, children: uiText("QUOTE MESSAGE") })] }), _jsxs(Animated.View, { ref: node => { anchor.current = node; if (quoteGesture.webRef)
|
|
535
536
|
quoteGesture.webRef.current = node; }, ...quoteGesture.handlers, accessibilityActions: quoting ? [{ name: "quote", label: uiText("Quote message") }] : undefined, onAccessibilityAction: event => { if (quoting && event.nativeEvent.actionName === "quote")
|
|
536
|
-
setReply(message); }, testID: `message-${message.kind}-${mine ? 'outgoing' : 'incoming'}`, style: { ...quoteGesture.webStyle, transform: [{ translateX: quoteGesture.offset }], ...(Platform.OS === "web" && !pendingStatus ? { touchAction: "pan-y", userSelect: "none" } : {}), alignSelf: mine ? 'flex-end' : 'flex-start', maxWidth: `${design.screens?.chat?.messageWidth ?? 88}%`, backgroundColor: mine ? c.outgoing : c.incoming,
|
|
537
|
+
setReply(message); }, testID: `message-${message.kind}-${mine ? 'outgoing' : 'incoming'}`, style: { ...quoteGesture.webStyle, transform: [{ translateX: quoteGesture.offset }], ...(Platform.OS === "web" && !pendingStatus ? { touchAction: "pan-y", userSelect: "none" } : {}), alignSelf: mine ? 'flex-end' : 'flex-start', maxWidth: `${design.screens?.chat?.messageWidth ?? 88}%`, backgroundColor: visual ? 'transparent' : mine ? c.outgoing : c.incoming, ...corners, ...(design.presentation?.bubbleStyle === 'top-tail' && !visual && !voice ? (mine ? { borderTopRightRadius: 0 } : { borderTopLeftRadius: 0 }) : {}), padding: visual ? 0 : 6, paddingBottom: visual ? 0 : canTranscript || canTranslate ? 3 : 6, ...(circleStatus && !visual && !voice && message.kind !== 'document' ? { paddingEnd: 26 } : {}), boxShadow: bigEmoji ? undefined : '0 1px 1px #00000010', ...((voice || message.kind === 'document') && !showingTransform ? { padding: 0, paddingBottom: 0, boxShadow: undefined, ...(voice ? { backgroundColor: 'transparent' } : {}) } : {}), ...(message.kind === 'poll' ? { backgroundColor: chatSurface(c.background), borderWidth: 1, borderColor: c.accent + '60', paddingHorizontal: 8, paddingTop: 4, paddingBottom: 2 } : {}), ...(bigEmoji ? { backgroundColor: 'transparent', paddingHorizontal: 4, paddingTop: 0, paddingBottom: 0 } : {}), ...(extra?.address || socialReady ? { flexDirection: mine ? 'row-reverse' : 'row', alignItems: 'center', gap: 8, padding: 0, paddingBottom: 0, backgroundColor: 'transparent', boxShadow: undefined } : {}) }, children: [design.presentation?.bubbleStyle === 'top-tail' && !visual && !voice && !extra && !socialReady && !bigEmoji && _jsx(View, { testID: "message-top-tail", pointerEvents: "none", style: { position: 'absolute', top: 0, ...(mine ? { right: -7 } : { left: -7 }), width: 0, height: 0, borderTopWidth: 10, borderTopColor: mine ? c.outgoing : c.incoming, ...(mine ? { borderRightWidth: 8, borderRightColor: 'transparent' } : { borderLeftWidth: 8, borderLeftColor: 'transparent' }) } }), extra?.address ? extraCard : socialReady ? socialCard : bubbleBody] })] });
|
|
537
538
|
});
|
|
538
539
|
export function MessageDeletion({ messages, onClose }) {
|
|
539
540
|
const messagingPopupColors = useMessagingPopupColors(undefined, 'alerts');
|
|
@@ -575,7 +576,7 @@ const MessagingHistoryRow = React.memo(function MessagingHistoryRow({ item, prev
|
|
|
575
576
|
const date = new Date(item.createdAt), start = !previous || date.toDateString() !== new Date(previous.createdAt).toDateString();
|
|
576
577
|
const checked = selection.some(m => m.id === item.id), selectable = selection.length > 0 && !item.pendingStatus && !item.deleted;
|
|
577
578
|
const toggle = () => setSelection(checked ? selection.filter(m => m.id !== item.id) : [...selection, item]);
|
|
578
|
-
return _jsxs(View, { testID: highlighted ? 'focused-message' : undefined, style: highlighted || checked ? { backgroundColor: design.colors.accent + '20', borderRadius: 8 } : undefined, children: [start && design.screens?.chat?.showDates !== false && _jsx(Text, { testID: "messaging-date-separator", style: { alignSelf: 'center', fontSize: design.screens?.chat?.dateSize ?? 12, color: design.screens?.chat?.dateText ?? design.colors.secondary, backgroundColor: design.screens?.chat?.dateBackground ?? chatSurface(design.colors.background), borderRadius: 7, paddingHorizontal: 12, paddingVertical: 5, marginTop: 4, marginBottom: 10 }, children: date.toDateString() === new Date().toDateString() ? uiText("Today") : date.toLocaleDateString(uiLocale, { month: 'short', day: 'numeric' }) }), _jsx(View, { style: { paddingLeft: selection.length ? 32 : 0 }, pointerEvents: selection.length ? 'none' : 'auto', accessibilityElementsHidden: selection.length > 0, importantForAccessibility: selection.length ? 'no-hide-descendants' : 'auto', ...(Platform.OS === 'web' && selection.length ? { 'aria-hidden': true } : {}), children: Message ? _jsx(Message, { message: item }) : _jsx(MessagingBubbleView, { message: item, pendingStatus: item.pendingStatus,
|
|
579
|
+
return _jsxs(View, { testID: highlighted ? 'focused-message' : undefined, style: highlighted || checked ? { backgroundColor: design.colors.accent + '20', borderRadius: 8 } : undefined, children: [start && design.screens?.chat?.showDates !== false && _jsx(Text, { testID: "messaging-date-separator", style: { alignSelf: 'center', fontSize: design.screens?.chat?.dateSize ?? 12, color: design.screens?.chat?.dateText ?? design.colors.secondary, backgroundColor: design.screens?.chat?.dateBackground ?? chatSurface(design.colors.background), borderRadius: 7, paddingHorizontal: 12, paddingVertical: 5, marginTop: 4, marginBottom: 10 }, children: date.toDateString() === new Date().toDateString() ? uiText("Today") : date.toLocaleDateString(uiLocale, { month: 'short', day: 'numeric' }) }), _jsx(View, { style: { paddingLeft: selection.length ? 32 : 0 }, pointerEvents: selection.length ? 'none' : 'auto', accessibilityElementsHidden: selection.length > 0, importantForAccessibility: selection.length ? 'no-hide-descendants' : 'auto', ...(Platform.OS === 'web' && selection.length ? { 'aria-hidden': true } : {}), children: Message ? _jsx(Message, { message: item }) : _jsx(MessagingBubbleView, { message: item, pendingStatus: item.pendingStatus, ui: bubbleUI }) }), selectable && _jsx(Pressable, { accessibilityRole: "checkbox", accessibilityLabel: uiText('Select message: {message}', { message: item.text || item.media?.fileName || uiText(mediaNames[item.kind] || 'Message') }), accessibilityState: { checked }, onPress: toggle, style: { position: 'absolute', inset: 0, justifyContent: 'center' }, children: _jsx(View, { style: { width: 24, height: 24, borderRadius: 12, borderWidth: 1, borderColor: design.colors.accent, backgroundColor: checked ? design.colors.accent : design.colors.background, alignItems: 'center', justifyContent: 'center' }, children: checked && _jsx(MessageIcon, { name: "check", size: 16, color: "#ffffff" }) }) })] });
|
|
579
580
|
});
|
|
580
581
|
const conversationReadingPositions = new WeakMap();
|
|
581
582
|
export function MessagingList() {
|
|
@@ -1084,7 +1085,7 @@ export function MessagingComposer() {
|
|
|
1084
1085
|
}
|
|
1085
1086
|
function renderTextComposer(voice = { hasVoice: false, blocked: false }) {
|
|
1086
1087
|
const blocked = voice.blocked || busy;
|
|
1087
|
-
return _jsxs(View, { style: { flexDirection: 'row', alignItems: 'flex-end', gap: 4 }, children: [_jsxs(View, { testID: "messaging-composer-field", style: { flex: 1, minWidth: 0, minHeight: 44, borderRadius: design.composer?.corners === 'square' ? 0 : design.composer?.corners === 'soft' ? 8 : 22, backgroundColor: design.composer?.fieldBackground ?? composerSurface(c.background), flexDirection: 'row', alignItems: 'flex-end', overflow: 'hidden' }, children: [(camera || library.image || library.video || library.document || !editing && (features?.poll || weatherAllowed)) && _jsx(Pressable, { ref: attachmentButton, accessibilityRole: "button", accessibilityLabel: uiText("Attach"), accessibilityState: { expanded: attachmentsOpen }, disabled: busy || blocked, onPress: () => { if (attachmentsOpen) {
|
|
1088
|
+
return _jsxs(View, { style: { flexDirection: 'row', alignItems: 'flex-end', gap: 4 }, children: [_jsxs(View, { testID: "messaging-composer-field", style: { flex: 1, minWidth: 0, minHeight: 44, borderRadius: design.composer?.corners === 'square' ? 0 : design.composer?.corners === 'soft' ? 8 : 22, backgroundColor: design.composer?.fieldBackground ?? composerSurface(c.background), flexDirection: 'row', alignItems: 'flex-end', overflow: 'hidden' }, children: [design.composer?.fieldBorder && _jsx(View, { testID: "messaging-composer-field-border", pointerEvents: "none", accessible: false, style: { position: 'absolute', top: 0, bottom: 0, left: 0, right: 0, zIndex: 1, borderWidth: 1, borderColor: design.composer.fieldBorderColor ?? c.secondary, borderRadius: design.composer?.corners === 'square' ? 0 : design.composer?.corners === 'soft' ? 8 : 22 } }), (camera || library.image || library.video || library.document || !editing && (features?.poll || weatherAllowed)) && _jsx(Pressable, { ref: attachmentButton, accessibilityRole: "button", accessibilityLabel: uiText("Attach"), accessibilityState: { expanded: attachmentsOpen }, disabled: busy || blocked, onPress: () => { if (attachmentsOpen) {
|
|
1088
1089
|
setAttachmentsOpen(false);
|
|
1089
1090
|
input.current?.focus();
|
|
1090
1091
|
}
|
|
@@ -48,6 +48,7 @@ export interface MessagingMediaDevice {
|
|
|
48
48
|
}
|
|
49
49
|
export interface MessagingMediaState {
|
|
50
50
|
phase: 'idle' | 'choosing' | 'preparing' | 'recording' | 'review' | 'uploading' | 'opening' | 'viewing' | 'failed';
|
|
51
|
+
previewUri?: string;
|
|
51
52
|
kind: MediaKind;
|
|
52
53
|
file: LocalMessagingMedia | null;
|
|
53
54
|
elapsedMs: number;
|
|
@@ -110,7 +111,7 @@ export declare class MessagingMediaController {
|
|
|
110
111
|
send(): Promise<void>;
|
|
111
112
|
/** View an owned cache copy of a draft. Closing never removes the original draft. */
|
|
112
113
|
previewLocal(file: LocalMessagingMedia, kind: MediaKind, message?: MessagingMessage): Promise<void>;
|
|
113
|
-
open(message: MessagingMessage, local?: () => Promise<LocalMessagingMedia | undefined
|
|
114
|
+
open(message: MessagingMessage, local?: () => Promise<LocalMessagingMedia | undefined>, previewUri?: string): Promise<void>;
|
|
114
115
|
/** Save/share a local copy of a playing stream without replacing its playback source. */
|
|
115
116
|
exportFile<T>(save: (file: LocalMessagingMedia, context: {
|
|
116
117
|
message: MessagingMessage | null;
|
package/dist/media-controller.js
CHANGED
|
@@ -154,7 +154,7 @@ export class MessagingMediaController {
|
|
|
154
154
|
this.resolve = null;
|
|
155
155
|
this.uploadId = '';
|
|
156
156
|
this.abort = null;
|
|
157
|
-
this.update({ phase: 'idle', file: null, error: null });
|
|
157
|
+
this.update({ phase: 'idle', previewUri: undefined, file: null, error: null });
|
|
158
158
|
resolve?.(media);
|
|
159
159
|
}
|
|
160
160
|
else if (selectionIntent === 'send' && !source)
|
|
@@ -265,7 +265,7 @@ export class MessagingMediaController {
|
|
|
265
265
|
this.resolve = null;
|
|
266
266
|
this.uploadId = '';
|
|
267
267
|
this.abort = null;
|
|
268
|
-
this.update({ phase: 'idle', file: null, error: null });
|
|
268
|
+
this.update({ phase: 'idle', previewUri: undefined, file: null, error: null });
|
|
269
269
|
resolve?.(media);
|
|
270
270
|
return;
|
|
271
271
|
}
|
|
@@ -288,7 +288,7 @@ export class MessagingMediaController {
|
|
|
288
288
|
this.abort = null;
|
|
289
289
|
if (this.stageRecording)
|
|
290
290
|
this.prepared.set(media.assetId, file);
|
|
291
|
-
this.update({ phase: 'idle', file: null, error: null });
|
|
291
|
+
this.update({ phase: 'idle', previewUri: undefined, file: null, error: null });
|
|
292
292
|
resolve?.(media);
|
|
293
293
|
if (!this.stageRecording)
|
|
294
294
|
await this.options.device.remove(file).catch(() => { });
|
|
@@ -311,7 +311,7 @@ export class MessagingMediaController {
|
|
|
311
311
|
this.abort = new AbortController();
|
|
312
312
|
this.update({ phase: 'viewing', kind, file, error: null, progress: 0 });
|
|
313
313
|
}
|
|
314
|
-
open(message, local) { return this.openMedia(message, undefined, local); }
|
|
314
|
+
open(message, local, previewUri) { return this.openMedia(message, undefined, local, previewUri); }
|
|
315
315
|
/** Save/share a local copy of a playing stream without replacing its playback source. */
|
|
316
316
|
async exportFile(save, options = {}) {
|
|
317
317
|
const file = this.state.file, generation = this.generation, message = this.openedMessage, conversationId = this.conversationId;
|
|
@@ -341,9 +341,9 @@ export class MessagingMediaController {
|
|
|
341
341
|
fallbackStream(uri, positionMs, autoPlay) {
|
|
342
342
|
if (!this.state.file?.stream || this.state.file.uri !== uri || !this.openedMessage)
|
|
343
343
|
return Promise.resolve();
|
|
344
|
-
return this.openMedia({ ...this.openedMessage, attachmentDownload: undefined }, { download: true, positionMs, autoPlay });
|
|
344
|
+
return this.openMedia({ ...this.openedMessage, attachmentDownload: undefined }, { download: true, positionMs, autoPlay }, undefined, this.state.previewUri);
|
|
345
345
|
}
|
|
346
|
-
async openMedia(message, recovery, local) {
|
|
346
|
+
async openMedia(message, recovery, local, previewUri) {
|
|
347
347
|
const intent = ++this.intent;
|
|
348
348
|
await this.closeCurrent();
|
|
349
349
|
if (intent !== this.intent)
|
|
@@ -355,7 +355,7 @@ export class MessagingMediaController {
|
|
|
355
355
|
const g = ++this.generation, abort = this.abort = new AbortController();
|
|
356
356
|
this.conversationId = message.conversationId;
|
|
357
357
|
this.openedMessage = message;
|
|
358
|
-
this.update({ phase: 'opening', kind: message.kind, file: null, error: null, progress: 0 });
|
|
358
|
+
this.update({ phase: 'opening', previewUri, kind: message.kind, file: null, error: null, progress: 0 });
|
|
359
359
|
try {
|
|
360
360
|
const context = { signal: abort.signal, onProgress: f => { if (this.isCurrent(g))
|
|
361
361
|
this.update({ progress: Math.max(0, Math.min(1, f)) }); } };
|
|
@@ -397,7 +397,7 @@ export class MessagingMediaController {
|
|
|
397
397
|
this.uploadId = '';
|
|
398
398
|
clearInterval(this.timer);
|
|
399
399
|
this.timer = undefined;
|
|
400
|
-
this.update({ phase: 'idle', file: null, error: null });
|
|
400
|
+
this.update({ phase: 'idle', previewUri: undefined, file: null, error: null });
|
|
401
401
|
resolve?.(null);
|
|
402
402
|
const work = (async () => {
|
|
403
403
|
if (stopping)
|
package/dist/media-ui.d.ts
CHANGED
|
@@ -44,13 +44,14 @@ export declare function MediaPlaybackControls({ playing, loading, positionMs, du
|
|
|
44
44
|
fullscreen?: boolean;
|
|
45
45
|
}): React.JSX.Element;
|
|
46
46
|
/** A full-size photo surface. The same tap-to-hide-controls, pinch and pan handling runs in the preview and native app. */
|
|
47
|
-
export declare function ZoomablePhoto({ uri, label, onTap, expanded }: {
|
|
47
|
+
export declare function ZoomablePhoto({ uri, previewUri, label, onTap, expanded }: {
|
|
48
48
|
uri: string;
|
|
49
|
+
previewUri?: string;
|
|
49
50
|
label?: string;
|
|
50
51
|
onTap?: () => void;
|
|
51
52
|
expanded?: boolean;
|
|
52
53
|
}): React.JSX.Element;
|
|
53
|
-
export declare function MediaViewer({ title, subtitle, kind, uri, fileName, byteSize, children, loading, error, onClose, onFileAction, reviewAction, onReview, onDownload, onShare, onForward, onDelete, showDelete, showForward, downloading, expanded, onExpandedChange, keepControlsVisible, status, transferProgress }: {
|
|
54
|
+
export declare function MediaViewer({ title, subtitle, kind, uri, previewUri, fileName, byteSize, children, loading, error, onClose, onFileAction, reviewAction, onReview, onDownload, onShare, onForward, onDelete, showDelete, showForward, downloading, expanded, onExpandedChange, keepControlsVisible, status, transferProgress }: {
|
|
54
55
|
showDelete?: boolean;
|
|
55
56
|
showForward?: boolean;
|
|
56
57
|
transferProgress?: number;
|
|
@@ -67,6 +68,7 @@ export declare function MediaViewer({ title, subtitle, kind, uri, fileName, byte
|
|
|
67
68
|
subtitle?: string;
|
|
68
69
|
kind: 'image' | 'video' | 'document' | 'voice';
|
|
69
70
|
uri?: string;
|
|
71
|
+
previewUri?: string;
|
|
70
72
|
fileName?: string;
|
|
71
73
|
byteSize?: number;
|
|
72
74
|
children?: ReactNode;
|