@robono/messaging-react-native 0.20.1 → 0.20.3
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/BRIDGE-MESSENGER.md +7 -1
- package/CHANGELOG.md +14 -0
- package/README.md +5 -1
- package/SBOM.spdx.json +168 -120
- package/dist/expo-media.js +8 -5
- package/dist/expo-screen.js +27 -25
- package/dist/index.js +6 -6
- package/dist/media-access.d.ts +18 -0
- package/dist/media-access.js +33 -0
- package/dist/media-controller.d.ts +2 -1
- package/dist/media-controller.js +14 -5
- package/dist/media-ui.d.ts +5 -2
- package/dist/media-ui.js +13 -8
- package/dist/message-menu.js +2 -2
- package/dist/recent-media.d.ts +5 -0
- package/dist/recent-media.js +47 -3
- package/package.json +2 -2
package/dist/expo-media.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { MessagingError } from '@robono/messaging';
|
|
2
|
+
import { MessagingMediaAccess } from './media-access.js';
|
|
2
3
|
import { awaitMediaScreening } from './media-screening';
|
|
3
4
|
import { AppState } from 'react-native';
|
|
4
5
|
import { prepareRecordingPermission } from './recording-permission.js';
|
|
@@ -264,6 +265,7 @@ function https(value) { const url = new URL(value); if (url.protocol !== 'https:
|
|
|
264
265
|
/** Private-storage transport. The endpoint is YOUR authenticated backend, never a Robono API key on the phone. */
|
|
265
266
|
export function createExpoMessagingStorage(options) {
|
|
266
267
|
const endpoint = https(options.url);
|
|
268
|
+
const access = new MessagingMediaAccess();
|
|
267
269
|
async function request(operation, input, signal) {
|
|
268
270
|
const token = await options.getAccessToken();
|
|
269
271
|
if (!token)
|
|
@@ -296,13 +298,12 @@ export function createExpoMessagingStorage(options) {
|
|
|
296
298
|
signal?.removeEventListener('abort', cancel);
|
|
297
299
|
}
|
|
298
300
|
}
|
|
299
|
-
async function playbackPlan(message, signal) {
|
|
301
|
+
async function playbackPlan(message, signal, reauthorize = false) {
|
|
300
302
|
check(signal);
|
|
301
303
|
if (message.deleted)
|
|
302
304
|
throw Error('This attachment is no longer available.');
|
|
303
|
-
const grant = message
|
|
304
|
-
const
|
|
305
|
-
const plan = granted ? { url: grant.url, media: message.media, headers: undefined } : await request('download', { conversationId: message.conversationId, messageId: message.id }, signal);
|
|
305
|
+
const grant = access.get(message, reauthorize);
|
|
306
|
+
const plan = grant ? { url: grant.url, media: message.media, headers: undefined } : await request('download', { conversationId: message.conversationId, messageId: message.id }, signal);
|
|
306
307
|
check(signal);
|
|
307
308
|
const media = plan.media;
|
|
308
309
|
if (!media || media.assetId !== message.media?.assetId || !Number.isSafeInteger(media.byteSize) || media.byteSize < 1 || media.byteSize > 104857600)
|
|
@@ -394,6 +395,8 @@ export function createExpoMessagingStorage(options) {
|
|
|
394
395
|
const media = plan.media;
|
|
395
396
|
if (media?.assetId !== message.media?.assetId || media?.mimeType !== 'image/jpeg' || !Number.isInteger(media.byteSize) || media.byteSize < 1 || media.byteSize > (message.media?.assetId.startsWith('bridge:') ? 204800 : 131072))
|
|
396
397
|
throw Error('Invalid attachment preview.');
|
|
398
|
+
check(context.signal);
|
|
399
|
+
access.remember(message, plan.attachmentDownload);
|
|
397
400
|
const path = await cachePath('preview.jpg');
|
|
398
401
|
try {
|
|
399
402
|
const task = FS.createDownloadResumable(https(plan.url), path, { headers: plan.headers ?? {}, sessionType: FS.FileSystemSessionType.FOREGROUND }, progress => { if (progress.totalBytesWritten > media.byteSize)
|
|
@@ -416,7 +419,7 @@ export function createExpoMessagingStorage(options) {
|
|
|
416
419
|
// Local directory preparation needs no media access. Run it alongside
|
|
417
420
|
// authorization, but never start the transfer until both have succeeded.
|
|
418
421
|
const [authorized, prepared] = await Promise.allSettled([
|
|
419
|
-
playbackPlan(message, context.signal),
|
|
422
|
+
playbackPlan(message, context.signal, context.reauthorize),
|
|
420
423
|
cacheDirectory(),
|
|
421
424
|
]);
|
|
422
425
|
const dir = prepared.status === 'fulfilled' ? prepared.value : null;
|
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 { Linking } from 'react-native';
|
|
3
|
+
import { isRemoteMessagingAsset } from './media-access.js';
|
|
3
4
|
import { ExpoDocumentPreview } from './expo-document.js';
|
|
4
5
|
import { MessagingTypography } from './typography.js';
|
|
5
6
|
import { Text } from './typography.js';
|
|
@@ -121,7 +122,7 @@ function VoicePlayer({ file, audio, design, inline, draft, autoPlay = false }) {
|
|
|
121
122
|
// Native file loading and audio-session preparation are independent. Start
|
|
122
123
|
// both now; playback still requires both and an active app.
|
|
123
124
|
const begin = () => {
|
|
124
|
-
if (!scope.alive || recovered.current || !autoPlay || started || cancelled || !scope.release || !player.isLoaded)
|
|
125
|
+
if (!scope.alive || recovered.current || !autoPlay || started || cancelled || !scope.release || (!player.isLoaded && (Platform.OS !== 'android' || !!file.resumeAtMs)))
|
|
125
126
|
return;
|
|
126
127
|
if (AppState.currentState !== 'active' || audio.isAvailable?.() === false) {
|
|
127
128
|
void stop();
|
|
@@ -129,7 +130,6 @@ function VoicePlayer({ file, audio, design, inline, draft, autoPlay = false }) {
|
|
|
129
130
|
}
|
|
130
131
|
started = true;
|
|
131
132
|
autoPreparing = false;
|
|
132
|
-
clearTimeout(startupTimeout);
|
|
133
133
|
void (async () => { if (file.resumeAtMs)
|
|
134
134
|
await player.seekTo(file.resumeAtMs / 1000); if (!scope.alive || cancelled || AppState.currentState !== 'active')
|
|
135
135
|
return; playIntent.current = true; player.play(); setPlaying(player.playing); })().catch(e => { if (!recoverStream())
|
|
@@ -181,6 +181,7 @@ function VoicePlayer({ file, audio, design, inline, draft, autoPlay = false }) {
|
|
|
181
181
|
setPosition(player.currentTime * 1000);
|
|
182
182
|
setPlaying(player.playing);
|
|
183
183
|
if (!reported && player.playing && player.currentTime > 0) {
|
|
184
|
+
clearTimeout(startupTimeout);
|
|
184
185
|
reported = true;
|
|
185
186
|
mediaReady('audio-playing', file.uri);
|
|
186
187
|
}
|
|
@@ -207,8 +208,8 @@ function VoicePlayer({ file, audio, design, inline, draft, autoPlay = false }) {
|
|
|
207
208
|
await releaseVoice(scope);
|
|
208
209
|
}
|
|
209
210
|
else {
|
|
210
|
-
if (!player.isLoaded)
|
|
211
|
-
|
|
211
|
+
if (!player.isLoaded && Platform.OS !== 'android')
|
|
212
|
+
return;
|
|
212
213
|
await stopVoicePlayers();
|
|
213
214
|
if (!await acquireVoice(scope, audio))
|
|
214
215
|
return;
|
|
@@ -216,7 +217,7 @@ function VoicePlayer({ file, audio, design, inline, draft, autoPlay = false }) {
|
|
|
216
217
|
await releaseVoice(scope);
|
|
217
218
|
return;
|
|
218
219
|
}
|
|
219
|
-
if (player.currentTime >= player.duration - .05)
|
|
220
|
+
if (player.duration > 0 && player.currentTime >= player.duration - .05)
|
|
220
221
|
await player.seekTo(0);
|
|
221
222
|
playIntent.current = true;
|
|
222
223
|
player.play();
|
|
@@ -236,7 +237,7 @@ function VoicePlayer({ file, audio, design, inline, draft, autoPlay = false }) {
|
|
|
236
237
|
const duration = file.durationMs ?? player.duration * 1000;
|
|
237
238
|
if (draft)
|
|
238
239
|
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 });
|
|
239
|
-
return _jsx(VoicePlayback, { 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())
|
|
240
|
+
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())
|
|
240
241
|
setError(uiText("Could not seek. Try again.")); }); } });
|
|
241
242
|
}
|
|
242
243
|
function VideoPlayer({ file, audio }) {
|
|
@@ -323,16 +324,7 @@ function FileViewer({ file, kind, audio, design }) {
|
|
|
323
324
|
return _jsx(VideoPlayer, { file: file, audio: audio, design: design });
|
|
324
325
|
if (kind === 'image')
|
|
325
326
|
return _jsxs(View, { children: [_jsx(Image, { source: { uri: file.uri }, resizeMode: "contain", accessibilityLabel: file.fileName, onError: () => setError(uiText("This image could not be displayed on this phone.")), style: { height: 300, width: '100%' } }), !!error && _jsx(Text, { style: { color: design.colors.foreground }, children: error })] });
|
|
326
|
-
return
|
|
327
|
-
void (async () => { try {
|
|
328
|
-
if (!await Sharing.isAvailableAsync())
|
|
329
|
-
throw Error('No file-opening menu is available.');
|
|
330
|
-
await Sharing.shareAsync(file.uri, { mimeType: file.mimeType, dialogTitle: file.fileName });
|
|
331
|
-
}
|
|
332
|
-
catch (e) {
|
|
333
|
-
setError(e instanceof Error ? e.message : uiText("The file could not be opened."));
|
|
334
|
-
} })();
|
|
335
|
-
} }), !!error && _jsx(Text, { accessibilityRole: "alert", style: { color: design.colors.foreground }, children: error })] });
|
|
327
|
+
return _jsx(ExpoDocumentPreview, { file: file });
|
|
336
328
|
}
|
|
337
329
|
export function MessagingMediaOverlay({ controller, audio, appearance, inlineVoice = false, inlineRecorder = false, viewerActions, onDismiss, onDownloadAttachment, mediaViewer, onDocumentLink }) {
|
|
338
330
|
const { text: uiText } = useRobonoLocale();
|
|
@@ -395,9 +387,10 @@ export function MessagingMediaOverlay({ controller, audio, appearance, inlineVoi
|
|
|
395
387
|
if ((typeof inlineVoice === 'function' ? inlineVoice() : inlineVoice) && state.kind === 'voice' && ['opening', 'viewing', 'failed'].includes(state.phase) && !review)
|
|
396
388
|
return null;
|
|
397
389
|
const actions = !review ? viewerActions?.() : undefined;
|
|
398
|
-
const viewer = state.file && (review || state.phase === 'viewing') ? _jsx(MediaViewer, { expanded: expanded, onExpandedChange: setExpanded, keepControlsVisible: mediaViewer?.keepControlsVisible ?? appearance.mediaViewer?.keepControlsVisible, status: status, kind: state.kind, uri: state.file
|
|
399
|
-
//
|
|
400
|
-
|
|
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;
|
|
391
|
+
// Present immediately: an iOS fade can still be dismissing when another attachment
|
|
392
|
+
// opens, leaving the next native modal invisible. Safe area belongs to this window.
|
|
393
|
+
return _jsx(Modal, { transparent: true, visible: state.phase !== 'idle' && state.phase !== 'choosing', onDismiss: onDismiss, animationType: "none", onRequestClose: () => { if (expanded)
|
|
401
394
|
setExpanded(false);
|
|
402
395
|
else
|
|
403
396
|
void controller.cancel(); }, children: _jsx(SafeAreaProvider, { style: { flex: 1, backgroundColor: state.kind === 'image' || state.kind === 'video' ? 'rgba(0,0,0,0.94)' : messagingPopupBackdrop }, children: _jsx(SafeAreaView, { edges: expanded ? [] : ['top', 'bottom', 'left', 'right'], style: { flex: 1 }, children: _jsx(View, { style: { flex: 1, margin: state.kind === 'image' || state.kind === 'video' ? 0 : 8, borderRadius: state.kind === 'image' || state.kind === 'video' ? 0 : 18, overflow: 'hidden', backgroundColor: state.kind === 'image' || state.kind === 'video' ? 'transparent' : '#000000' }, children: viewer ?? (_jsx(View, { style: { flex: 1, backgroundColor: c.background }, children: _jsxs(ScrollView, { contentContainerStyle: { padding: 8, paddingTop: 0, gap: 12, flexGrow: 1 }, children: [_jsx(MessagingPopupHeader, { title: state.kind === 'voice' ? uiText("Voice message") : state.kind === 'image' ? uiText("Photo") : state.kind === 'video' ? uiText("Video") : uiText("File"), foreground: c.foreground, closeLabel: uiText("Close attachment"), onClose: () => void controller.cancel() }), state.phase === 'recording' ? _jsxs(View, { style: { alignItems: 'center', gap: 20, paddingVertical: 32 }, children: [_jsx(MaterialIcons, { name: "mic", size: 48, color: c.accent }), _jsx(Text, { style: { color: c.foreground, fontSize: 32, fontVariant: ['tabular-nums'] }, children: time(state.elapsedMs) }), _jsx(Text, { style: { color: c.secondary }, children: uiText('{time} remaining', { time: time(Math.max(0, state.maxDurationMs - state.elapsedMs)) }) }), _jsx(Control, { label: uiText("Stop recording"), icon: "stop", color: c.accent, onPress: () => void controller.finishRecording() })] }) : null, ['choosing', 'preparing', 'uploading', 'opening'].includes(state.phase) && _jsx(Text, { accessibilityRole: "progressbar", accessibilityValue: { min: 0, max: 100, now: Math.round(state.progress * 100) }, style: { color: c.foreground, fontSize: 18 }, children: state.phase === 'uploading' ? (state.processing ? uiText('Checking attachment… You can cancel.') : uiText('Uploading… {progress}%', { progress: Math.round(state.progress * 100) })) : state.phase === 'opening' ? (state.progress > 0 ? uiText('Opening… {progress}%', { progress: Math.round(state.progress * 100) }) : uiText('Opening…')) : state.phase === 'choosing' ? uiText("Choose an attachment.") : uiText("Preparing recording…") }), state.file && _jsxs(_Fragment, { children: [_jsx(Text, { style: { color: c.foreground, fontSize: 16 }, children: state.file.fileName }), _jsx(Text, { style: { color: c.secondary }, children: size(state.file.byteSize) }), (review || state.phase === 'viewing') && _jsx(FileViewer, { file: state.file, kind: state.kind, audio: audio, design: appearance }, state.file.uri)] }), state.error && _jsx(Text, { accessibilityRole: "alert", style: { color: c.foreground }, children: state.error }), review && (state.phase === 'review' || state.retryUpload) && _jsx(Control, { label: state.phase === 'failed' ? uiText("Retry upload") : uiText("Add attachment"), icon: state.phase === 'failed' ? 'refresh' : 'send', color: c.accent, onPress: () => void controller.send() })] }) })) }) }) }) });
|
|
@@ -443,6 +436,8 @@ function ExpoMessagingScreenContent({ storage, audioSession, renderConversation,
|
|
|
443
436
|
const present = controller.getPrepared(media.assetId) ?? recorder.getPrepared(media.assetId);
|
|
444
437
|
if (present)
|
|
445
438
|
return present;
|
|
439
|
+
if (isRemoteMessagingAsset(media.assetId))
|
|
440
|
+
return undefined;
|
|
446
441
|
const conversationId = props.client.getSnapshot().conversationId, saved = await outbox?.file(conversationId, media.assetId);
|
|
447
442
|
if (!saved)
|
|
448
443
|
return undefined;
|
|
@@ -550,11 +545,18 @@ function ExpoMessagingScreenContent({ storage, audioSession, renderConversation,
|
|
|
550
545
|
void Haptics.selectionAsync().catch(() => { }); }, []);
|
|
551
546
|
const defaultCopyText = useCallback(async (text) => { await Clipboard.setStringAsync(text); }, []);
|
|
552
547
|
const components = useMemo(() => ({ PrivacyLayer: ExpoMessagingPrivacyLayer, SocialPlayer, TranslationVoice, VoiceMessage: InlineVoice, VoiceComposer: InlineComposer, VoiceAttachment, ...props.components }), [SocialPlayer, TranslationVoice, InlineVoice, InlineComposer, VoiceAttachment, props.components]);
|
|
553
|
-
const openAttachment = useCallback(async (m) => {
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
await controller.open(m
|
|
548
|
+
const openAttachment = useCallback(async (m) => {
|
|
549
|
+
const intent = ++openingIntent.current;
|
|
550
|
+
opened.current = { messageId: m.id, kind: m.kind, started: Date.now(), reported: new Set() };
|
|
551
|
+
message.current = m;
|
|
552
|
+
await controller.open(m, async () => {
|
|
553
|
+
await stopVoicePlayers();
|
|
554
|
+
if (intent !== openingIntent.current)
|
|
555
|
+
return undefined;
|
|
556
|
+
const draft = m.media && m.kind !== 'text' && m.kind !== 'poll' ? await restore(m.media, m.kind) : undefined;
|
|
557
|
+
return draft ? copyMessagingCache(draft) : undefined;
|
|
558
|
+
});
|
|
559
|
+
}, [restore, controller]);
|
|
558
560
|
const screenProps = { ...props, requestedMessageAction,
|
|
559
561
|
onQuoteReady: props.onQuoteReady ?? defaultQuoteReady,
|
|
560
562
|
copyText: props.copyText ?? defaultCopyText,
|
|
@@ -612,7 +614,7 @@ function ExpoMessagingScreenContent({ storage, audioSession, renderConversation,
|
|
|
612
614
|
afterViewer.current = { kind, messageId: m.id, sequence: Date.now() };
|
|
613
615
|
void controller.cancel().then(() => {
|
|
614
616
|
// Some installed native runtimes omit onDismiss after a media modal closes.
|
|
615
|
-
// Keep the normal event fast path;
|
|
617
|
+
// Keep the normal event fast path; retain a recovery delay for older native runtimes.
|
|
616
618
|
// Navigation/unmount clears the queued action, so it cannot open in another chat.
|
|
617
619
|
if (afterViewer.current)
|
|
618
620
|
dismissFallback.current = setTimeout(viewerDismissed, Platform.OS === 'ios' ? 500 : 250);
|
package/dist/index.js
CHANGED
|
@@ -43,7 +43,7 @@ export { MessagingSafety } from './safety.js';
|
|
|
43
43
|
import { PollMessage, PollComposer } from "./polls.js";
|
|
44
44
|
export { PollMessage, PollComposer } from "./polls.js";
|
|
45
45
|
import React, { createContext, useContext, useMemo, useCallback, useEffect, useRef, useState, useSyncExternalStore, } from "react";
|
|
46
|
-
import { Animated, ActivityIndicator, AppState, BackHandler, FlatList, Image, Keyboard, Linking, Platform, Pressable, ScrollView, View, useWindowDimensions, } from "react-native";
|
|
46
|
+
import { Animated, ActivityIndicator, AppState, BackHandler, FlatList, Image, Keyboard, Linking, Platform, Pressable, ScrollView, StyleSheet, View, useWindowDimensions, } from "react-native";
|
|
47
47
|
import { useQuoteGesture, messageInfoRevealWidth, messageReplyRevealWidth } from "./use-quote-gesture.js";
|
|
48
48
|
import { MessageIcon, duration, fileSize, chatSurface, composerSurface } from "./icons.js";
|
|
49
49
|
import { VoiceMessageComposer } from "./voice-composer.js";
|
|
@@ -350,7 +350,7 @@ function QuotedPreview({ message, ink }) {
|
|
|
350
350
|
}, [message?.id, message?.conversationId, message?.media?.assetId, message?.deleted, attachmentPreview]);
|
|
351
351
|
const name = message && !message.deleted ? (message.senderId === userId ? 'You' : participants?.[message.senderId]?.name ?? (state.conversation?.kind === 'direct' ? contact.name : 'Chat member')) : null;
|
|
352
352
|
const media = message && !message.deleted && message.kind !== 'text' && message.kind !== 'poll';
|
|
353
|
-
return _jsxs(View, { style: { flexDirection: 'row', alignItems: '
|
|
353
|
+
return _jsxs(View, { testID: "quoted-message-preview", style: { flexDirection: 'row', alignItems: 'flex-start', gap: 8, minWidth: 0 }, children: [media && (thumbnail ? _jsx(Image, { accessibilityLabel: uiText("Quoted attachment thumbnail"), source: { uri: thumbnail }, onError: () => setThumbnail(undefined), resizeMode: "cover", style: { width: 42, height: 42, borderRadius: 8 } }) : _jsx(MessageIcon, { name: message.kind === 'voice' ? 'mic' : message.kind, color: design.colors.accent, size: 24 })), _jsxs(View, { style: { flexShrink: 1, minWidth: 0 }, children: [name && _jsx(Text, { numberOfLines: 1, style: { color: design.colors.accent, fontSize: 11, lineHeight: 14, fontWeight: '900' }, children: name === 'You' ? uiText('You') : name }), _jsxs(Text, { numberOfLines: 2, style: { color: ink, fontSize: 12, lineHeight: 16, opacity: .8, marginTop: name ? 1 : 0 }, children: [message?.deleted ? uiText("Message deleted") : quoteSummary(message, uiText), message?.kind === 'voice' && message.media?.durationMs ? ` · ${duration(message.media.durationMs)}` : ''] })] })] });
|
|
354
354
|
}
|
|
355
355
|
/** Thumbnails stay local to the view and are discarded on conversation/message changes. */
|
|
356
356
|
const heardVoiceMessages = new WeakMap();
|
|
@@ -372,7 +372,7 @@ function MediaContent({ message, ink, footer, onOpen, onLongPress }) {
|
|
|
372
372
|
}
|
|
373
373
|
if (message.kind === 'image' || message.kind === 'video')
|
|
374
374
|
return _jsx(View, { style: { width: 220, maxWidth: '100%', gap: 0 }, children: _jsxs(View, { style: { height: 155, borderRadius: 10, 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) })] })] }) });
|
|
375
|
-
return _jsxs(View, { style: { flexDirection: 'row', alignItems: 'center', gap:
|
|
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, borderRadius: 10 }, 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
376
|
}
|
|
377
377
|
function messageTimeLabel(message, format, text) { return (message.editedAt && !message.deleted ? text('edited') + ' · ' : '') + format(message.createdAt); }
|
|
378
378
|
function MessageMetadata({ mine, ink, pendingStatus }) {
|
|
@@ -526,14 +526,14 @@ const MessagingBubbleView = React.memo(function MessagingBubbleView({ message, p
|
|
|
526
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;
|
|
527
527
|
const regionProps = { message, mine, appearance: design, pendingStatus };
|
|
528
528
|
const bodyContent = components?.MessageBody && !message.deleted ? _jsx(components.MessageBody, { ...regionProps, children: content }) : content;
|
|
529
|
-
const bubbleBody = _jsxs(_Fragment, { children: [!bigEmoji && (!mine || !deliveryStatus) && _jsx(View, { testID: mine ? (message.readAt && state.settings?.features.readReceipts ? 'message-status-read' : 'message-status-sent') : 'message-status-incoming', pointerEvents: "none", accessible: false, style: { position: 'absolute', top: joinsBefore ? -(messageGap + 2) / 2 : 0, bottom: joinsAfter ? -(messageGap + 2) / 2 : 0, start: 0, end: 0, zIndex: 40, ...(mine ? { borderEndWidth: 2, borderEndColor: message.readAt && state.settings?.features.readReceipts ? c.accent : c.foreground, borderTopEndRadius: joinsBefore ? 0 : voice && !message.text && !showingTransform ? 24 : bubbleRadius, borderBottomEndRadius: joinsAfter ? 0 : voice && !message.text && !showingTransform ? 24 : bubbleRadius } : { borderStartWidth: 2, borderStartColor: '#2B2B2B', borderTopStartRadius: joinsBefore ? 0 : voice && !message.text && !showingTransform ? 24 : bubbleRadius, borderBottomStartRadius: joinsAfter ? 0 : voice && !message.text && !showingTransform ? 24 : bubbleRadius }) } }), 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: {
|
|
529
|
+
const bubbleBody = _jsxs(_Fragment, { children: [!bigEmoji && (!mine || !deliveryStatus) && _jsx(View, { testID: mine ? (message.readAt && state.settings?.features.readReceipts ? 'message-status-read' : 'message-status-sent') : 'message-status-incoming', pointerEvents: "none", accessible: false, style: { position: 'absolute', top: joinsBefore ? -(messageGap + 2) / 2 : 0, bottom: joinsAfter ? -(messageGap + 2) / 2 : 0, start: 0, end: 0, zIndex: 40, ...(mine ? { borderEndWidth: 2, borderEndColor: message.readAt && state.settings?.features.readReceipts ? c.accent : c.foreground, borderTopEndRadius: joinsBefore ? 0 : voice && !message.text && !showingTransform ? 24 : bubbleRadius, borderBottomEndRadius: joinsAfter ? 0 : voice && !message.text && !showingTransform ? 24 : bubbleRadius } : { borderStartWidth: 2, borderStartColor: '#2B2B2B', borderTopStartRadius: joinsBefore ? 0 : voice && !message.text && !showingTransform ? 24 : bubbleRadius, borderBottomStartRadius: joinsAfter ? 0 : voice && !message.text && !showingTransform ? 24 : bubbleRadius }) } }), 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
530
|
return; if (extra?.address)
|
|
531
531
|
extraRef.current?.open();
|
|
532
532
|
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, { selectable: true, onLongPress: menu, style: { color: ink, fontSize: 16, lineHeight: 22, marginTop:
|
|
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
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") })] }), _jsx(Animated.View, { ref: node => { anchor.current = node; if (quoteGesture.webRef)
|
|
535
535
|
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, borderRadius: bubbleRadius, padding: visual ? 3 : 6, paddingBottom: visual || canTranscript || canTranslate ? 3 : 6, boxShadow: bigEmoji ? undefined : '0 1px 1px #00000010', ...(voice
|
|
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, borderRadius: bubbleRadius, padding: visual ? 3 : 6, paddingBottom: visual || canTranscript || canTranslate ? 3 : 6, boxShadow: bigEmoji ? undefined : '0 1px 1px #00000010', ...((voice || message.kind === 'document') && !showingTransform ? { padding: 0, paddingBottom: 0, boxShadow: undefined, ...(!message.text && 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: extra?.address ? extraCard : socialReady ? socialCard : bubbleBody })] });
|
|
537
537
|
});
|
|
538
538
|
export function MessageDeletion({ messages, onClose }) {
|
|
539
539
|
const messagingPopupColors = useMessagingPopupColors(undefined, 'alerts');
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { MessagingMessage } from '@robono/messaging';
|
|
2
|
+
export declare const isRemoteMessagingAsset: (id: string) => boolean;
|
|
3
|
+
/** Access belongs to this authorized message object, never a global URL cache.
|
|
4
|
+
* Explicit exports still request fresh authorization. */
|
|
5
|
+
export declare class MessagingMediaAccess {
|
|
6
|
+
private now;
|
|
7
|
+
private grants;
|
|
8
|
+
constructor(now?: () => number);
|
|
9
|
+
private valid;
|
|
10
|
+
remember(message: MessagingMessage, grant: unknown): void;
|
|
11
|
+
get(message: MessagingMessage, reauthorize?: boolean): {
|
|
12
|
+
url: string;
|
|
13
|
+
expiresAt: number;
|
|
14
|
+
messageId: string;
|
|
15
|
+
conversationId: string;
|
|
16
|
+
assetId: string;
|
|
17
|
+
} | undefined;
|
|
18
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export const isRemoteMessagingAsset = (id) => id.startsWith('bridge:') || id.startsWith('robono-r2:');
|
|
2
|
+
/** Access belongs to this authorized message object, never a global URL cache.
|
|
3
|
+
* Explicit exports still request fresh authorization. */
|
|
4
|
+
export class MessagingMediaAccess {
|
|
5
|
+
now;
|
|
6
|
+
grants = new WeakMap();
|
|
7
|
+
constructor(now = Date.now) {
|
|
8
|
+
this.now = now;
|
|
9
|
+
}
|
|
10
|
+
valid(message, grant) {
|
|
11
|
+
if (message.deleted || !message.media || !grant || grant.messageId !== message.id || grant.conversationId !== message.conversationId || grant.assetId !== message.media.assetId || !Number.isFinite(grant.expiresAt) || grant.expiresAt <= this.now() + 5000 || grant.expiresAt > this.now() + 60000)
|
|
12
|
+
return false;
|
|
13
|
+
try {
|
|
14
|
+
const url = new URL(grant.url);
|
|
15
|
+
return url.protocol === 'https:' && !url.username && !url.password;
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
remember(message, grant) { if (this.valid(message, grant))
|
|
22
|
+
this.grants.set(message, { ...grant }); }
|
|
23
|
+
get(message, reauthorize = false) {
|
|
24
|
+
if (reauthorize)
|
|
25
|
+
return undefined;
|
|
26
|
+
const grant = this.grants.get(message) ?? message.attachmentDownload;
|
|
27
|
+
if (!this.valid(message, grant)) {
|
|
28
|
+
this.grants.delete(message);
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
return grant;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -10,6 +10,7 @@ export interface LocalMessagingMedia extends Omit<MessageMedia, 'assetId'> {
|
|
|
10
10
|
autoPlay?: boolean;
|
|
11
11
|
}
|
|
12
12
|
export interface MediaTransferOptions {
|
|
13
|
+
reauthorize?: boolean;
|
|
13
14
|
signal: AbortSignal;
|
|
14
15
|
onProgress: (fraction: number) => void;
|
|
15
16
|
onProcessing?: () => void;
|
|
@@ -109,7 +110,7 @@ export declare class MessagingMediaController {
|
|
|
109
110
|
send(): Promise<void>;
|
|
110
111
|
/** View an owned cache copy of a draft. Closing never removes the original draft. */
|
|
111
112
|
previewLocal(file: LocalMessagingMedia, kind: MediaKind, message?: MessagingMessage): Promise<void>;
|
|
112
|
-
open(message: MessagingMessage): Promise<void>;
|
|
113
|
+
open(message: MessagingMessage, local?: () => Promise<LocalMessagingMedia | undefined>): Promise<void>;
|
|
113
114
|
/** Save/share a local copy of a playing stream without replacing its playback source. */
|
|
114
115
|
exportFile<T>(save: (file: LocalMessagingMedia, context: {
|
|
115
116
|
message: MessagingMessage | null;
|
package/dist/media-controller.js
CHANGED
|
@@ -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) { return this.openMedia(message); }
|
|
314
|
+
open(message, local) { return this.openMedia(message, undefined, local); }
|
|
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;
|
|
@@ -324,7 +324,7 @@ export class MessagingMediaController {
|
|
|
324
324
|
return save(file, { message, signal });
|
|
325
325
|
if (!message || !this.abort)
|
|
326
326
|
throw Error('The attachment is unavailable.');
|
|
327
|
-
const copy = await this.options.storage.download(options.reauthorize ? { ...message, attachmentDownload: undefined } : message, { signal: this.abort.signal, onProgress: value => { if (this.isCurrent(generation))
|
|
327
|
+
const copy = await this.options.storage.download(options.reauthorize ? { ...message, attachmentDownload: undefined } : message, { reauthorize: options.reauthorize, signal: this.abort.signal, onProgress: value => { if (this.isCurrent(generation))
|
|
328
328
|
this.update({ progress: Math.max(0, Math.min(1, value)) }); } });
|
|
329
329
|
try {
|
|
330
330
|
if (!this.isCurrent(generation) || this.options.getConversationId() !== conversationId)
|
|
@@ -343,7 +343,7 @@ export class MessagingMediaController {
|
|
|
343
343
|
return Promise.resolve();
|
|
344
344
|
return this.openMedia({ ...this.openedMessage, attachmentDownload: undefined }, { download: true, positionMs, autoPlay });
|
|
345
345
|
}
|
|
346
|
-
async openMedia(message, recovery) {
|
|
346
|
+
async openMedia(message, recovery, local) {
|
|
347
347
|
const intent = ++this.intent;
|
|
348
348
|
await this.closeCurrent();
|
|
349
349
|
if (intent !== this.intent)
|
|
@@ -359,9 +359,18 @@ export class MessagingMediaController {
|
|
|
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)) }); } };
|
|
362
|
-
const
|
|
363
|
-
if (!this.isCurrent(g))
|
|
362
|
+
const prepared = await local?.();
|
|
363
|
+
if (!this.isCurrent(g)) {
|
|
364
|
+
if (prepared)
|
|
365
|
+
await this.options.device.remove(prepared);
|
|
364
366
|
return;
|
|
367
|
+
}
|
|
368
|
+
const remote = prepared ?? (!recovery?.download && ['voice', 'video'].includes(message.kind) ? await this.options.storage.stream?.(message, context) : null);
|
|
369
|
+
if (!this.isCurrent(g)) {
|
|
370
|
+
if (remote)
|
|
371
|
+
await this.options.device.remove(remote);
|
|
372
|
+
return;
|
|
373
|
+
}
|
|
365
374
|
const file = remote ?? await this.options.storage.download(message, context);
|
|
366
375
|
if (!this.isCurrent(g) || this.options.getConversationId() !== message.conversationId) {
|
|
367
376
|
await this.options.device.remove(file);
|
package/dist/media-ui.d.ts
CHANGED
|
@@ -26,7 +26,8 @@ export interface PlaybackProps {
|
|
|
26
26
|
onRate?: () => void;
|
|
27
27
|
}
|
|
28
28
|
/** Same chat controls on web, iOS and Android. Audio engines supply state, not a different UI. */
|
|
29
|
-
export declare function VoicePlayback({ ink, accent, waveform, showWaveform, footer, onLongPress, mine, heard, onPlayed, background, playing, loading, positionMs, durationMs, error, onToggle, onSeek }: PlaybackProps & {
|
|
29
|
+
export declare function VoicePlayback({ message, ink, accent, waveform, showWaveform, footer, onLongPress, mine, heard, onPlayed, background, playing, loading, positionMs, durationMs, error, onToggle, onSeek }: PlaybackProps & {
|
|
30
|
+
message?: MessagingMessage;
|
|
30
31
|
ink: string;
|
|
31
32
|
accent: string;
|
|
32
33
|
waveform?: number[];
|
|
@@ -49,7 +50,9 @@ export declare function ZoomablePhoto({ uri, label, onTap, expanded }: {
|
|
|
49
50
|
onTap?: () => void;
|
|
50
51
|
expanded?: boolean;
|
|
51
52
|
}): React.JSX.Element;
|
|
52
|
-
export declare function MediaViewer({ title, subtitle, kind, uri, fileName, byteSize, children, loading, error, onClose, onFileAction, reviewAction, onReview, onDownload, onShare, onForward, onDelete, downloading, expanded, onExpandedChange, keepControlsVisible, status, transferProgress }: {
|
|
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
|
+
showDelete?: boolean;
|
|
55
|
+
showForward?: boolean;
|
|
53
56
|
transferProgress?: number;
|
|
54
57
|
status?: string;
|
|
55
58
|
keepControlsVisible?: boolean;
|
package/dist/media-ui.js
CHANGED
|
@@ -10,7 +10,7 @@ import { ActivityIndicator, Image, PanResponder, Platform, Pressable, View } fro
|
|
|
10
10
|
import { MediaReadiness } from './media-readiness.js';
|
|
11
11
|
import { MessageIcon, duration, fileSize } from './icons.js';
|
|
12
12
|
/** Same chat controls on web, iOS and Android. Audio engines supply state, not a different UI. */
|
|
13
|
-
export function VoicePlayback({ ink, accent, waveform, showWaveform = true, footer, onLongPress, mine = false, heard = false, onPlayed, background, playing = false, loading = false, positionMs = 0, durationMs = 0, error, onToggle, onSeek }) {
|
|
13
|
+
export function VoicePlayback({ message, ink, accent, waveform, showWaveform = true, footer, onLongPress, mine = false, heard = false, onPlayed, background, playing = false, loading = false, positionMs = 0, durationMs = 0, error, onToggle, onSeek }) {
|
|
14
14
|
const { text: uiText, locale: uiLocale, number: uiNumber, count: uiCount } = useRobonoLocale();
|
|
15
15
|
const width = useRef(1), held = useRef(false), [played, setPlayed] = useState(false), progress = durationMs ? Math.max(0, Math.min(1, positionMs / durationMs)) : 0;
|
|
16
16
|
useEffect(() => { if (playing && positionMs > 0) {
|
|
@@ -23,7 +23,7 @@ export function VoicePlayback({ ink, accent, waveform, showWaveform = true, foot
|
|
|
23
23
|
const buttonInk = buttonOverride ? messagingContrastInk(buttonOverride) : ink;
|
|
24
24
|
const bars = showWaveform ? messengerVoiceWaveform(waveform, durationMs) : null, fill = voiceStyle?.waveform ?? (mine ? ink : accent);
|
|
25
25
|
const hold = () => { held.current = true; onLongPress?.(); };
|
|
26
|
-
return _jsxs(View, { testID: "voice-message-player", style: { width: 220, maxWidth: '100%', minHeight: 44, borderRadius: 24, borderWidth: 1, borderColor: ink + '24', backgroundColor: background ?? (mine ? '#1F5F7A' : '#1D1D1D'), paddingLeft: 5, paddingRight: 8, paddingVertical: 3 }, children: [_jsxs(View, { style: { flexDirection: 'row', direction: 'ltr', alignItems: 'center', gap: 8 }, children: [_jsx(Pressable, { testID: "voice-play-control", accessibilityRole: "button", accessibilityLabel: playing ? uiText("Pause voice message") : uiText("Play voice message"), accessibilityState: { busy: loading }, disabled: loading, hitSlop: 6, delayLongPress: 360, onPressIn: () => { held.current = false; }, onPress: () => { if (!held.current)
|
|
26
|
+
return _jsxs(View, { testID: "voice-message-player", style: { width: 220, maxWidth: '100%', minHeight: 44, borderRadius: 24, borderWidth: 1, borderColor: ink + '24', backgroundColor: background ?? (mine ? '#1F5F7A' : '#1D1D1D'), paddingLeft: 5, paddingRight: 8, paddingVertical: 3, ...(message?.text ? { borderWidth: 0, paddingTop: 0, paddingBottom: 1 } : {}) }, children: [_jsxs(View, { style: { flexDirection: 'row', direction: 'ltr', alignItems: 'center', gap: 8 }, children: [_jsx(Pressable, { testID: "voice-play-control", accessibilityRole: "button", accessibilityLabel: playing ? uiText("Pause voice message") : uiText("Play voice message"), accessibilityState: { busy: loading }, disabled: loading, hitSlop: 6, delayLongPress: 360, onPressIn: () => { held.current = false; }, onPress: () => { if (!held.current)
|
|
27
27
|
onToggle(); }, onLongPress: hold, style: { width: 36, height: 36, borderRadius: 18, paddingLeft: playing ? 0 : 2, backgroundColor: buttonColor, alignItems: 'center', justifyContent: 'center' }, children: loading ? _jsx(ActivityIndicator, { size: "small", color: buttonInk }) : _jsx(MessageIcon, { name: playing ? 'pause' : 'play', color: buttonInk, size: 20 }) }), _jsxs(View, { style: { flex: 1, minWidth: 0, gap: 7 }, children: [_jsx(Pressable, { onLongPress: hold, accessibilityRole: "adjustable", accessibilityLabel: showWaveform ? uiText("Voice waveform") : uiText("Voice position"), accessibilityValue: { min: 0, max: Math.ceil(durationMs / 1000), now: Math.floor(positionMs / 1000) }, accessibilityActions: [{ name: 'increment', label: uiText("Forward five seconds") }, { name: 'decrement', label: uiText("Back five seconds") }], onAccessibilityAction: e => onSeek?.(Math.max(0, Math.min(durationMs, positionMs + (e.nativeEvent.actionName === 'increment' ? 5000 : -5000)))), onLayout: e => { width.current = e.nativeEvent.layout.width; }, onPressIn: () => { held.current = false; }, onPress: e => { if (held.current)
|
|
28
28
|
return; const bounds = Platform.OS === 'web' ? e.currentTarget.getBoundingClientRect() : null; const x = bounds ? e.nativeEvent.clientX - bounds.left : e.nativeEvent.locationX; const total = bounds?.width ?? width.current; if (total > 0 && Number.isFinite(x))
|
|
29
29
|
onSeek?.(Math.max(0, Math.min(1, x / total)) * durationMs); }, style: { height: bars ? 24 : 9, transform: [{ translateY: 4 }], flexDirection: 'row', alignItems: 'center', gap: 1 }, children: bars ? bars.map((sample, i) => _jsx(View, { pointerEvents: "none", style: { flex: 1, flexBasis: 0, borderRadius: 2, overflow: 'hidden', backgroundColor: ink + (mine ? '33' : '38'), height: 2 + sample * 18 }, children: _jsx(View, { style: { height: '100%', backgroundColor: fill, width: `${Math.max(0, Math.min(1, progress * bars.length - i)) * 100}%` } }) }, i)) : _jsx(View, { pointerEvents: "none", style: { flex: 1, height: 9, borderRadius: 5, overflow: 'hidden', backgroundColor: ink + '33' }, children: _jsx(View, { style: { height: 9, borderRadius: 5, backgroundColor: fill, width: `${progress * 100}%` } }) }) }), _jsxs(View, { style: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', gap: 4, paddingRight: footer ? 6 : 0 }, children: [_jsx(Text, { testID: "voice-duration", style: { color: ink, opacity: .75, fontSize: 11, fontWeight: '800', fontVariant: ['tabular-nums'] }, children: duration(playing || positionMs > 0 ? Math.max(0, durationMs - positionMs) : durationMs) }), footer && _jsx(View, { testID: "voice-message-actions", style: { flexShrink: 1, maxWidth: 112, alignItems: 'flex-end' }, children: footer })] })] })] }), !!error && _jsx(Text, { accessibilityRole: "alert", style: { color: ink, fontSize: 12, marginTop: 6 }, children: error })] });
|
|
@@ -41,7 +41,7 @@ export function ZoomablePhoto({ uri, label, onTap, expanded = false }) {
|
|
|
41
41
|
label ??= uiText('Photo');
|
|
42
42
|
const mediaReady = useContext(MediaReadiness), appearance = useMessagingAppearance();
|
|
43
43
|
const [transform, setTransform] = useState({ zoom: 1, x: 0, y: 0 }), [error, setError] = useState(false);
|
|
44
|
-
const [viewport, setViewport] = useState({ width: 1, height: 1 }), [imageSize, setImageSize] = useState({ width:
|
|
44
|
+
const [viewport, setViewport] = useState({ width: 1, height: 1 }), [imageSize, setImageSize] = useState({ width: 0, height: 0, uri: "" });
|
|
45
45
|
const rotated = expanded && imageSize.width > imageSize.height && viewport.height > viewport.width;
|
|
46
46
|
const rotation = useRef(rotated);
|
|
47
47
|
rotation.current = rotated;
|
|
@@ -105,13 +105,18 @@ export function ZoomablePhoto({ uri, label, onTap, expanded = false }) {
|
|
|
105
105
|
}, [controller, uri]);
|
|
106
106
|
useEffect(() => { let active = true; controller.reset(); setError(false); Image.getSize(uri, (width, height) => { if (active) {
|
|
107
107
|
controller.image(width, height);
|
|
108
|
-
setImageSize({ width, height });
|
|
109
|
-
} }, () => {
|
|
108
|
+
setImageSize({ width, height, uri });
|
|
109
|
+
} }, () => { if (active)
|
|
110
|
+
setError(true); }); return () => { active = false; }; }, [uri, controller]);
|
|
110
111
|
useEffect(() => { controller.reset(); }, [expanded, controller]);
|
|
111
112
|
useEffect(() => { controller.layout(stageWidth, stageHeight); }, [controller, stageWidth, stageHeight]);
|
|
112
|
-
|
|
113
|
+
// Resize the actual image as Messenger does. A transform-only zoom can keep
|
|
114
|
+
// Android's decoded bitmap at its small initial display resolution.
|
|
115
|
+
const contain = imageSize.width && imageSize.height ? Math.min(stageWidth / imageSize.width, stageHeight / imageSize.height) : 1;
|
|
116
|
+
const imageWidth = (imageSize.width || stageWidth) * contain * transform.zoom, imageHeight = (imageSize.height || stageHeight) * contain * transform.zoom;
|
|
117
|
+
return _jsxs(View, { style: { flex: 1, minHeight: 0, overflow: 'hidden', alignItems: 'center', justifyContent: 'center' }, onLayout: e => setViewport(e.nativeEvent.layout), children: [_jsx(View, { testID: "photo-image-stage", style: { width: stageWidth, height: stageHeight, transform: rotated ? [{ rotate: '90deg' }] : [] }, children: _jsx(View, { ref: webRef, ...(Platform.OS === 'web' ? {} : pan.panHandlers), testID: "photo-gesture-surface", accessible: true, accessibilityRole: "button", accessibilityLabel: uiText("Toggle photo controls"), onAccessibilityTap: () => tap.current?.(), ...(Platform.OS === 'web' ? { tabIndex: 0 } : {}), style: { flex: 1, overflow: 'hidden', ...(Platform.OS === 'web' ? { touchAction: 'none', userSelect: 'none' } : {}) }, children: imageSize.uri === uri && viewport.width > 1 && viewport.height > 1 && _jsx(Image, { testID: "photo-zoom-image", accessibilityLabel: label, source: { uri }, resizeMode: "contain", onLoad: () => mediaReady('image-loaded', uri), onError: () => setError(true), style: { position: 'absolute', width: imageWidth, height: imageHeight, left: (stageWidth - imageWidth) / 2 + transform.x, top: (stageHeight - imageHeight) / 2 + transform.y } }) }) }), error && _jsx(Text, { accessibilityRole: "alert", style: { position: 'absolute', top: '50%', alignSelf: 'center', color: messagingMediaColors(appearance).foreground }, children: uiText("This photo could not be opened.") })] });
|
|
113
118
|
}
|
|
114
|
-
export function MediaViewer({ title, subtitle, kind, uri, fileName, byteSize, children, loading, error, onClose, onFileAction, reviewAction, onReview, onDownload, onShare, onForward, onDelete, downloading = false, expanded, onExpandedChange, keepControlsVisible = false, status, transferProgress }) {
|
|
119
|
+
export function MediaViewer({ title, subtitle, kind, uri, fileName, byteSize, children, loading, error, onClose, onFileAction, reviewAction, onReview, onDownload, onShare, onForward, onDelete, showDelete = false, showForward = false, downloading = false, expanded, onExpandedChange, keepControlsVisible = false, status, transferProgress }) {
|
|
115
120
|
const { text: uiText, locale: uiLocale, number: uiNumber, count: uiCount } = useRobonoLocale();
|
|
116
121
|
const appearance = useMessagingAppearance(), c = messagingMediaColors(appearance), actionBackground = appearance?.mediaViewer?.accent ?? '#ffffff';
|
|
117
122
|
const [localExpanded, setLocalExpanded] = useState(false);
|
|
@@ -119,5 +124,5 @@ export function MediaViewer({ title, subtitle, kind, uri, fileName, byteSize, ch
|
|
|
119
124
|
const setExpanded = (value) => { setLocalExpanded(value); onExpandedChange?.(value); };
|
|
120
125
|
useEffect(() => { setLocalExpanded(false); }, [uri]);
|
|
121
126
|
const visual = kind === 'image' || kind === 'video';
|
|
122
|
-
return _jsxs(View, { testID: "messenger-media-viewer", accessibilityViewIsModal: true, style: { flex: 1, minHeight: 0, backgroundColor: appearance?.mediaViewer?.background ?? (controls ? 'rgba(0,0,0,0.94)' : '#000000') }, children: [_jsxs(View, { style: { flex: 1, minHeight: 0, justifyContent: 'center', paddingHorizontal: visual && controls ? 12 : 0 }, children: [controls && _jsxs(View, { testID: "media-action-toolbar", style: { position: 'absolute', top: 12, left: 12, right: 12, zIndex: 3, minHeight: 52, borderRadius: c.radius, borderWidth: 1, borderColor: c.foreground + '1f', backgroundColor: c.controls + 'eb', paddingLeft: 8, paddingRight: 4, flexDirection: 'row', alignItems: 'center', gap: 2 }, children: [[[
|
|
127
|
+
return _jsxs(View, { testID: "messenger-media-viewer", accessibilityViewIsModal: true, style: { flex: 1, minHeight: 0, backgroundColor: appearance?.mediaViewer?.background ?? (controls ? 'rgba(0,0,0,0.94)' : '#000000') }, children: [_jsxs(View, { style: { flex: 1, minHeight: 0, justifyContent: 'center', paddingHorizontal: visual && controls ? 12 : 0 }, children: [controls && _jsxs(View, { testID: "media-action-toolbar", style: { position: 'absolute', top: 12, left: 12, right: 12, zIndex: 3, minHeight: 52, borderRadius: c.radius, borderWidth: 1, borderColor: c.foreground + '1f', backgroundColor: c.controls + 'eb', paddingLeft: 8, paddingRight: 4, flexDirection: 'row', alignItems: 'center', gap: 2 }, children: [[[onDownload, 'Download', 'download-outline', downloading, false], [onDelete, 'Delete', 'trash-outline', false, true], [onForward, 'Forward', 'arrow-redo-outline', false, false], [onShare, 'Share', 'share-social-outline', false, false]].filter(([action, label]) => !!action || label === 'Delete' && showDelete || label === 'Forward' && showForward).map(([action, label, icon, busy, destructive]) => _jsxs(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText("{value1} media", { value1: label }), accessibilityState: { busy }, disabled: !action || busy || downloading || loading, onPress: action, style: { opacity: !action ? .5 : 1, flex: 1, minWidth: 44, minHeight: 44, borderRadius: Math.min(22, c.radius), alignItems: 'center', justifyContent: 'center', gap: 1, paddingHorizontal: 2 }, children: [busy ? _jsx(ActivityIndicator, { size: "small", color: c.accent }) : _jsx(MessageIcon, { name: icon, size: 20, color: !action ? c.foreground + '88' : destructive ? c.danger : c.foreground }), _jsx(Text, { numberOfLines: 1, style: { color: !action ? c.foreground + '88' : destructive ? c.danger : c.foreground, fontSize: 10, fontWeight: '800' }, children: label })] }, label)), _jsx(View, { style: { flex: (!visual || !!reviewAction) && !onDownload && !onDelete && !onForward && !onShare ? 1 : 0, minWidth: 0 }, children: (!visual || !!reviewAction) && !onDownload && !onDelete && !onForward && !onShare && _jsx(Text, { numberOfLines: 1, style: { color: c.foreground, fontSize: 14, paddingLeft: 8 }, children: title }) }), _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText("Close media"), onPress: onClose, style: { width: 44, height: 44, borderRadius: Math.min(22, c.radius), backgroundColor: c.foreground + '14', alignItems: 'center', justifyContent: 'center' }, children: _jsx(MessageIcon, { name: "close", size: 24, color: c.foreground }) })] }), loading ? _jsx(View, { style: { flex: 1, alignItems: 'center', justifyContent: 'center', gap: 16 }, children: _jsx(ActivityIndicator, { accessibilityLabel: uiText("Loading attachment"), color: c.foreground }) }) : kind === 'image' && uri ? _jsx(View, { style: { height: controls ? '88%' : '100%', width: '100%' }, children: _jsx(ZoomablePhoto, { uri: uri, label: fileName, expanded: photoExpanded, onTap: () => setExpanded(!photoExpanded) }) }) : kind === 'document' && children ? _jsx(View, { style: { flex: 1, minHeight: 0, paddingTop: 76 }, children: children }) : kind === 'document' ? _jsxs(View, { style: { flex: 1, alignItems: 'center', justifyContent: 'center', padding: 32, gap: 20 }, children: [_jsx(View, { style: { width: 88, height: 106, borderRadius: 16, backgroundColor: c.foreground + '12', alignItems: 'center', justifyContent: 'center' }, children: _jsx(MessageIcon, { name: "document", color: c.foreground, size: 40 }) }), _jsx(Text, { style: { color: c.foreground, fontSize: 19, fontWeight: '600', textAlign: 'center' }, children: fileName }), _jsxs(Text, { style: { color: c.foreground, fontSize: 13 }, children: [fileName?.split('.').pop()?.toUpperCase(), " \u00B7 ", fileSize(byteSize)] })] }) : kind === 'video' ? _jsx(View, { testID: "media-video-stage", style: { height: '72%', width: '100%' }, children: children }) : children] }), !controls && _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText("Close media"), onPress: onClose, style: { position: "absolute", top: 12, right: 12, width: 44, height: 44, borderRadius: Math.min(22, c.radius), backgroundColor: c.controls + 'cc', alignItems: "center", justifyContent: "center" }, children: _jsx(MessageIcon, { name: "close", color: c.foreground, size: 24 }) }), downloading && transferProgress !== undefined && _jsx(View, { accessibilityRole: "progressbar", accessibilityValue: { min: 0, max: 100, now: Math.round(transferProgress * 100) }, style: { height: 3, backgroundColor: c.foreground + '22' }, children: _jsx(View, { style: { height: 3, width: `${Math.round(transferProgress * 100)}%`, backgroundColor: c.accent } }) }), !!status && _jsx(Text, { accessibilityLiveRegion: "polite", style: { color: c.foreground, padding: 12 }, children: status }), !!error && _jsx(Text, { accessibilityRole: "alert", style: { color: c.foreground, padding: 16 }, children: error }), controls && reviewAction && onReview && _jsx(View, { style: { padding: 16, borderTopWidth: 1, borderTopColor: c.foreground + '15' }, children: _jsx(Pressable, { accessibilityRole: "button", onPress: onReview, style: { minHeight: 48, borderRadius: 24, backgroundColor: actionBackground, alignItems: 'center', justifyContent: 'center' }, children: _jsx(Text, { style: { fontWeight: '600', color: messagingContrastInk(actionBackground) }, children: reviewAction }) }) })] });
|
|
123
128
|
}
|
package/dist/message-menu.js
CHANGED
|
@@ -3,7 +3,7 @@ import { defaultMessagingSettings, messagingMenuColors, messagingMenuLayout, mes
|
|
|
3
3
|
import { useMessagingAppearance } from './appearance-context.js';
|
|
4
4
|
import { Text } from './typography.js';
|
|
5
5
|
import { useRobonoLocale } from './localization.js';
|
|
6
|
-
import {
|
|
6
|
+
import { MessagingMenuSurface } from './popup.js';
|
|
7
7
|
import { useEffect } from 'react';
|
|
8
8
|
import { Platform, Pressable, ScrollView, View } from 'react-native';
|
|
9
9
|
import { MessageIcon } from './icons.js';
|
|
@@ -31,6 +31,6 @@ export function MessageMenu({ visible, position, screenHeight, mine, reactions,
|
|
|
31
31
|
const menuWidth = Math.min(300, rect.width - 24), y = Math.max(12, Math.min(position.y - rect.top, rect.height - 12));
|
|
32
32
|
const local = { ...position, x: Math.max(12, Math.min(position.x - rect.left, rect.width - menuWidth - 12)), y, available: Math.max(44, (position.above ? y : rect.height - y) - 24) };
|
|
33
33
|
const card = _jsx(View, { testID: "message-action-card", style: { width: 218, maxWidth: '100%', maxHeight: Math.min(310, Math.max(43, local.available - (reactions ? 58 : 0))), borderRadius: layout.radius, borderWidth: .5, borderColor: palette.foreground + '22', backgroundColor: palette.background, paddingVertical: 4, overflow: 'hidden', boxShadow: '0 8px 18px #0006', alignSelf: mine ? 'flex-end' : 'flex-start' }, children: _jsx(ScrollView, { showsVerticalScrollIndicator: false, bounces: false, keyboardShouldPersistTaps: "handled", children: children }) });
|
|
34
|
-
return _jsxs(View, { style: { flex: 1 }, children: [_jsx(Pressable, { accessibilityLabel: uiText("Close message options"), onPress: onClose, style: { position: 'absolute', inset: 0, backgroundColor:
|
|
34
|
+
return _jsxs(View, { style: { flex: 1 }, children: [_jsx(Pressable, { testID: "message-options-dismiss", accessibilityLabel: uiText("Close message options"), onPress: onClose, style: { position: 'absolute', inset: 0, backgroundColor: 'transparent' } }), _jsxs(View, { testID: "message-context-menu", style: { position: 'absolute', left: local.x, ...(position.above ? { bottom: rect.height - local.y + 12 } : { top: local.y + 12 }), width: menuWidth, maxWidth: '94%', gap: 8 }, children: [position.above ? card : reactions, position.above ? reactions : card] })] });
|
|
35
35
|
} });
|
|
36
36
|
}
|