@robono/messaging-react-native 0.20.2 → 0.21.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/BRIDGE-MESSENGER.md +7 -1
- package/CHANGELOG.md +12 -1
- package/README.md +36 -0
- package/SBOM.spdx.json +348 -204
- 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-media.js +15 -27
- package/dist/expo-screen.js +18 -7
- 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/index.js +8 -5
- 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 +8 -8
- package/dist/media-ui.d.ts +4 -2
- package/dist/media-ui.js +13 -13
- package/dist/message-menu.js +2 -2
- package/dist/preview-cache.d.ts +1 -0
- package/dist/preview-cache.js +2 -0
- package/dist/recent-media.d.ts +5 -0
- package/dist/recent-media.js +26 -1
- 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 +3 -3
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;
|
package/dist/media-ui.js
CHANGED
|
@@ -12,7 +12,8 @@ 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
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
|
-
const width = useRef(1), held = useRef(false), [played, setPlayed] = useState(false)
|
|
15
|
+
const width = useRef(1), held = useRef(false), [played, setPlayed] = useState(false);
|
|
16
|
+
const displayPosition = !playing && durationMs > 0 && positionMs >= durationMs ? 0 : positionMs, progress = durationMs ? Math.max(0, Math.min(1, displayPosition / durationMs)) : 0;
|
|
16
17
|
useEffect(() => { if (playing && positionMs > 0) {
|
|
17
18
|
setPlayed(true);
|
|
18
19
|
onPlayed?.();
|
|
@@ -23,10 +24,10 @@ export function VoicePlayback({ message, ink, accent, waveform, showWaveform = t
|
|
|
23
24
|
const buttonInk = buttonOverride ? messagingContrastInk(buttonOverride) : ink;
|
|
24
25
|
const bars = showWaveform ? messengerVoiceWaveform(waveform, durationMs) : null, fill = voiceStyle?.waveform ?? (mine ? ink : accent);
|
|
25
26
|
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
|
|
27
|
+
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)
|
|
27
28
|
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
29
|
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
|
-
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 ||
|
|
30
|
+
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 || displayPosition > 0 ? Math.max(0, durationMs - displayPosition) : 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 })] });
|
|
30
31
|
}
|
|
31
32
|
export function MediaPlaybackControls({ playing = false, loading = false, positionMs = 0, durationMs = 0, error, onToggle, onSeek, onFullscreen, fullscreen = false }) {
|
|
32
33
|
const { text: uiText, locale: uiLocale, number: uiNumber, count: uiCount } = useRobonoLocale();
|
|
@@ -36,11 +37,11 @@ export function MediaPlaybackControls({ playing = false, loading = false, positi
|
|
|
36
37
|
onSeek?.(Math.max(0, Math.min(1, x / total)) * durationMs); }, style: { flex: 1, height: 44, justifyContent: 'center' }, children: _jsx(View, { style: { height: 3, borderRadius: 2, backgroundColor: c.foreground + '44' }, children: _jsx(View, { style: { height: 3, borderRadius: 2, backgroundColor: appearance?.mediaViewer?.accent ?? '#ffffff', width: `${durationMs ? Math.min(100, positionMs / durationMs * 100) : 0}%` } }) }) }), _jsx(Text, { style: { color: c.foreground, fontSize: 12, fontVariant: ['tabular-nums'] }, children: duration(durationMs) }), onFullscreen && _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: fullscreen ? uiText("Exit full screen") : uiText("Full screen video"), disabled: loading, onPress: onFullscreen, style: { width: 44, height: 44, alignItems: "center", justifyContent: "center" }, children: _jsx(MessageIcon, { name: fullscreen ? "close" : "open-in-new", color: c.foreground, size: 22 }) })] }), !!error && _jsx(Text, { accessibilityRole: "alert", style: { color: c.foreground, fontSize: 13 }, children: error })] });
|
|
37
38
|
}
|
|
38
39
|
/** A full-size photo surface. The same tap-to-hide-controls, pinch and pan handling runs in the preview and native app. */
|
|
39
|
-
export function ZoomablePhoto({ uri, label, onTap, expanded = false }) {
|
|
40
|
+
export function ZoomablePhoto({ uri, previewUri, label, onTap, expanded = false }) {
|
|
40
41
|
const { text: uiText, locale: uiLocale, number: uiNumber, count: uiCount } = useRobonoLocale();
|
|
41
42
|
label ??= uiText('Photo');
|
|
42
43
|
const mediaReady = useContext(MediaReadiness), appearance = useMessagingAppearance();
|
|
43
|
-
const [transform, setTransform] = useState({ zoom: 1, x: 0, y: 0 }), [error, setError] = useState(false);
|
|
44
|
+
const [transform, setTransform] = useState({ zoom: 1, x: 0, y: 0 }), [error, setError] = useState(false), [loadedUri, setLoadedUri] = useState('');
|
|
44
45
|
const [viewport, setViewport] = useState({ width: 1, height: 1 }), [imageSize, setImageSize] = useState({ width: 0, height: 0, uri: "" });
|
|
45
46
|
const rotated = expanded && imageSize.width > imageSize.height && viewport.height > viewport.width;
|
|
46
47
|
const rotation = useRef(rotated);
|
|
@@ -103,20 +104,19 @@ export function ZoomablePhoto({ uri, label, onTap, expanded = false }) {
|
|
|
103
104
|
element.addEventListener('dragstart', prevent);
|
|
104
105
|
return () => { active.clear(); controller.end([], true); element.removeEventListener('pointerdown', down); element.removeEventListener('pointermove', move); element.removeEventListener('pointerup', end); element.removeEventListener('pointercancel', end); element.removeEventListener('lostpointercapture', end); element.removeEventListener('wheel', wheel); element.removeEventListener('keydown', key); element.removeEventListener('dragstart', prevent); };
|
|
105
106
|
}, [controller, uri]);
|
|
106
|
-
useEffect(() => {
|
|
107
|
-
controller.image(width, height);
|
|
108
|
-
setImageSize({ width, height, uri });
|
|
109
|
-
} }, () => { if (active)
|
|
110
|
-
setError(true); }); return () => { active = false; }; }, [uri, controller]);
|
|
107
|
+
useEffect(() => { controller.reset(); setError(false); }, [uri, controller]);
|
|
111
108
|
useEffect(() => { controller.reset(); }, [expanded, controller]);
|
|
112
109
|
useEffect(() => { controller.layout(stageWidth, stageHeight); }, [controller, stageWidth, stageHeight]);
|
|
113
110
|
// Resize the actual image as Messenger does. A transform-only zoom can keep
|
|
114
111
|
// Android's decoded bitmap at its small initial display resolution.
|
|
115
112
|
const contain = imageSize.width && imageSize.height ? Math.min(stageWidth / imageSize.width, stageHeight / imageSize.height) : 1;
|
|
116
113
|
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:
|
|
114
|
+
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: _jsxs(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: [previewUri && loadedUri !== uri && _jsx(Image, { testID: "media-loading-preview", source: { uri: previewUri }, resizeMode: "contain", style: { position: 'absolute', width: '100%', height: '100%' } }), viewport.width > 1 && viewport.height > 1 && _jsx(Image, { testID: "photo-zoom-image", accessibilityLabel: label, source: { uri }, resizeMode: "contain", onLoad: event => { const target = event.nativeEvent.target; const { width, height } = event.nativeEvent.source ?? { width: target?.naturalWidth ?? 0, height: target?.naturalHeight ?? 0 }; if (width > 0 && height > 0) {
|
|
115
|
+
controller.image(width, height);
|
|
116
|
+
setImageSize({ width, height, uri });
|
|
117
|
+
} setLoadedUri(uri); 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.") })] });
|
|
118
118
|
}
|
|
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 }) {
|
|
119
|
+
export function MediaViewer({ title, subtitle, kind, uri, previewUri, 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 }) {
|
|
120
120
|
const { text: uiText, locale: uiLocale, number: uiNumber, count: uiCount } = useRobonoLocale();
|
|
121
121
|
const appearance = useMessagingAppearance(), c = messagingMediaColors(appearance), actionBackground = appearance?.mediaViewer?.accent ?? '#ffffff';
|
|
122
122
|
const [localExpanded, setLocalExpanded] = useState(false);
|
|
@@ -124,5 +124,5 @@ export function MediaViewer({ title, subtitle, kind, uri, fileName, byteSize, ch
|
|
|
124
124
|
const setExpanded = (value) => { setLocalExpanded(value); onExpandedChange?.(value); };
|
|
125
125
|
useEffect(() => { setLocalExpanded(false); }, [uri]);
|
|
126
126
|
const visual = kind === 'image' || kind === 'video';
|
|
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 ?
|
|
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 ? _jsxs(View, { style: { flex: 1, alignItems: 'center', justifyContent: 'center', gap: 16 }, children: [visual && previewUri && _jsx(Image, { testID: "media-loading-preview", source: { uri: previewUri }, resizeMode: "contain", style: { position: 'absolute', width: '100%', height: '88%' } }), _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, previewUri: previewUri, 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] }), 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 }) }) })] });
|
|
128
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
|
}
|
package/dist/preview-cache.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export declare class MessagingPreviewCache {
|
|
|
17
17
|
timeoutMs: number;
|
|
18
18
|
}, now?: () => number);
|
|
19
19
|
get(key: string, load: (signal: AbortSignal) => Promise<Preview>): Promise<Preview>;
|
|
20
|
+
peek(key: string): Preview | undefined;
|
|
20
21
|
invalidate(key: string): void;
|
|
21
22
|
clear(): void;
|
|
22
23
|
private drop;
|
package/dist/preview-cache.js
CHANGED
|
@@ -29,6 +29,7 @@ export class MessagingPreviewCache {
|
|
|
29
29
|
this.pump();
|
|
30
30
|
return promise;
|
|
31
31
|
}
|
|
32
|
+
peek(key) { const entry = this.entries.get(key); return entry && !entry.abort.signal.aborted && entry.expires > this.now() ? entry.value : undefined; }
|
|
32
33
|
invalidate(key) { const entry = this.entries.get(key); if (entry)
|
|
33
34
|
this.drop(entry); }
|
|
34
35
|
clear() { for (const entry of this.entries.values())
|
|
@@ -51,6 +52,7 @@ export class MessagingPreviewCache {
|
|
|
51
52
|
void Promise.race([Promise.resolve().then(() => entry.abort.signal.aborted ? {} : entry.load(entry.abort.signal)), cancelled]).then(value => {
|
|
52
53
|
if (entry.abort.signal.aborted || this.entries.get(entry.key) !== entry)
|
|
53
54
|
return;
|
|
55
|
+
entry.value = value;
|
|
54
56
|
entry.expires = this.now() + this.options.ttlMs;
|
|
55
57
|
entry.resolve(value);
|
|
56
58
|
if (!value.uri && !value.waveform)
|
package/dist/recent-media.d.ts
CHANGED
|
@@ -8,6 +8,8 @@ export declare class RecentMessagingMedia {
|
|
|
8
8
|
private now;
|
|
9
9
|
private entries;
|
|
10
10
|
private running;
|
|
11
|
+
private foreground;
|
|
12
|
+
private resumeTimer;
|
|
11
13
|
constructor(source: MessagingMediaStorage, files: {
|
|
12
14
|
copy: (file: LocalMessagingMedia) => Promise<LocalMessagingMedia>;
|
|
13
15
|
remove: (file: LocalMessagingMedia) => Promise<void>;
|
|
@@ -15,6 +17,9 @@ export declare class RecentMessagingMedia {
|
|
|
15
17
|
readonly storage: MessagingMediaStorage;
|
|
16
18
|
sync(messages: MessagingMessage[]): void;
|
|
17
19
|
clear(): void;
|
|
20
|
+
/** Pause speculation until the viewer closes/cancels, including while a
|
|
21
|
+
* streamed video is fetching bytes after its URL has been returned. */
|
|
22
|
+
private prioritize;
|
|
18
23
|
private drop;
|
|
19
24
|
private pump;
|
|
20
25
|
private start;
|
package/dist/recent-media.js
CHANGED
|
@@ -7,6 +7,8 @@ export class RecentMessagingMedia {
|
|
|
7
7
|
now;
|
|
8
8
|
entries = new Map();
|
|
9
9
|
running = 0;
|
|
10
|
+
foreground = new Map();
|
|
11
|
+
resumeTimer;
|
|
10
12
|
constructor(source, files, now = Date.now) {
|
|
11
13
|
this.source = source;
|
|
12
14
|
this.files = files;
|
|
@@ -17,6 +19,7 @@ export class RecentMessagingMedia {
|
|
|
17
19
|
stream: async (message, context) => {
|
|
18
20
|
if (context.signal.aborted)
|
|
19
21
|
throw Error('Cancelled.');
|
|
22
|
+
this.prioritize(context.signal, this.source.stream ? undefined : key(message));
|
|
20
23
|
const id = key(message), entry = this.entries.get(id);
|
|
21
24
|
// An already authorized original starts locally. Never wait behind a
|
|
22
25
|
// speculative transfer: a cold tap keeps the normal streaming path.
|
|
@@ -34,6 +37,9 @@ export class RecentMessagingMedia {
|
|
|
34
37
|
},
|
|
35
38
|
upload: (file, context) => this.source.upload(file, context), discard: id => this.source.discard(id),
|
|
36
39
|
download: async (message, context) => {
|
|
40
|
+
if (context.signal.aborted)
|
|
41
|
+
throw Error('Cancelled.');
|
|
42
|
+
this.prioritize(context.signal, key(message));
|
|
37
43
|
if (context.reauthorize)
|
|
38
44
|
return this.source.download(message, context);
|
|
39
45
|
const id = key(message), entry = this.entries.get(id);
|
|
@@ -100,8 +106,25 @@ export class RecentMessagingMedia {
|
|
|
100
106
|
}
|
|
101
107
|
this.pump();
|
|
102
108
|
}
|
|
103
|
-
clear() { for (const [
|
|
109
|
+
clear() { clearTimeout(this.resumeTimer); for (const [signal, release] of this.foreground)
|
|
110
|
+
signal.removeEventListener('abort', release); this.foreground.clear(); for (const [id, entry] of this.entries)
|
|
104
111
|
this.drop(id, entry); }
|
|
112
|
+
/** Pause speculation until the viewer closes/cancels, including while a
|
|
113
|
+
* streamed video is fetching bytes after its URL has been returned. */
|
|
114
|
+
prioritize(signal, keep) {
|
|
115
|
+
clearTimeout(this.resumeTimer);
|
|
116
|
+
if (!this.foreground.has(signal)) {
|
|
117
|
+
const release = () => { signal.removeEventListener('abort', release); this.foreground.delete(signal); clearTimeout(this.resumeTimer); this.resumeTimer = setTimeout(() => this.pump(), 0); };
|
|
118
|
+
this.foreground.set(signal, release);
|
|
119
|
+
signal.addEventListener('abort', release, { once: true });
|
|
120
|
+
}
|
|
121
|
+
for (const [id, entry] of this.entries) {
|
|
122
|
+
if (id === keep || entry.file || !entry.work)
|
|
123
|
+
continue;
|
|
124
|
+
this.drop(id, entry);
|
|
125
|
+
this.entries.set(id, { message: entry.message, abort: new AbortController(), expires: 0, attempted: false });
|
|
126
|
+
}
|
|
127
|
+
}
|
|
105
128
|
drop(id, entry) {
|
|
106
129
|
if (this.entries.get(id) === entry)
|
|
107
130
|
this.entries.delete(id);
|
|
@@ -112,6 +135,8 @@ export class RecentMessagingMedia {
|
|
|
112
135
|
}
|
|
113
136
|
}
|
|
114
137
|
pump() {
|
|
138
|
+
if (this.foreground.size)
|
|
139
|
+
return;
|
|
115
140
|
for (const [id, entry] of this.entries) {
|
|
116
141
|
if (this.running >= 2)
|
|
117
142
|
break;
|
package/dist/voice-composer.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { messengerRecordingWaveform } from './voice-waveform.js';
|
|
2
3
|
import { Text } from './typography.js';
|
|
3
4
|
import { useRobonoLocale } from './localization.js';
|
|
4
5
|
import { ActivityIndicator, Pressable, View } from 'react-native';
|
|
5
6
|
import { MessageIcon, duration, composerSurface } from './icons.js';
|
|
6
7
|
function Waveform({ samples = [], color }) {
|
|
7
8
|
const { text: uiText, locale: uiLocale, number: uiNumber, count: uiCount } = useRobonoLocale();
|
|
8
|
-
return _jsx(View, { accessibilityLabel: uiText("Recording waveform"), style: { flex: 1, minWidth: 0, height:
|
|
9
|
+
return _jsx(View, { accessibilityLabel: uiText("Recording waveform"), style: { flex: 1, minWidth: 0, height: 28, flexDirection: 'row', alignItems: 'center', gap: 2, overflow: 'hidden' }, children: messengerRecordingWaveform(samples).map((value, i) => _jsx(View, { testID: "recording-waveform-bar", style: { flex: 1, minWidth: 2, borderRadius: 2, height: 2 + value * 24, backgroundColor: color, opacity: samples.length ? 1 : .25 } }, i)) });
|
|
9
10
|
}
|
|
10
11
|
/** Messenger's inline recorder; adapters supply media state and the optional text composer. */
|
|
11
12
|
export function VoiceMessageComposer({ appearance, maxSeconds, busy, onRecord, actions, phase = 'idle', elapsedMs = 0, waveform, error, review, onStop, onSend, onRemove, renderTextComposer, renderAttachments }) {
|
package/dist/voice-waveform.d.ts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
/** Messenger playback display normalization; never changes the stored recording. */
|
|
2
2
|
export declare function messengerVoiceWaveform(value: number[] | undefined, durationMs: number): number[];
|
|
3
|
+
/** Original Messenger's live meter emphasis, for display only. Silence stays flat. */
|
|
4
|
+
export declare function messengerRecordingWaveform(samples?: number[]): number[];
|
package/dist/voice-waveform.js
CHANGED
|
@@ -19,3 +19,12 @@ export function messengerVoiceWaveform(value, durationMs) {
|
|
|
19
19
|
const factor = Math.max(.75, Math.min((durationMs || 2200) / 2800, 1.35));
|
|
20
20
|
return Array.from({ length: count }, (_, i) => Math.max(.08, Math.min(.9, Math.sin(Math.PI * i / (count - 1)) * (.38 + .34 * Math.sin((i + 1) * 1.73 * factor) + .18 * Math.sin((i + 3) * .67)))));
|
|
21
21
|
}
|
|
22
|
+
/** Original Messenger's live meter emphasis, for display only. Silence stays flat. */
|
|
23
|
+
export function messengerRecordingWaveform(samples = []) {
|
|
24
|
+
const levels = samples.slice(-56), count = 28;
|
|
25
|
+
return Array.from({ length: count }, (_, i) => {
|
|
26
|
+
const start = Math.floor(i * levels.length / count), end = Math.max(start + 1, Math.floor((i + 1) * levels.length / count));
|
|
27
|
+
const value = Math.max(0, ...levels.slice(start, end).filter(Number.isFinite));
|
|
28
|
+
return value <= .001 ? 0 : Math.max(.04, Math.min(1, Math.pow(value, .46) * 1.35));
|
|
29
|
+
});
|
|
30
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@robono/messaging-react-native",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"description": "Optional, composable direct and group messaging screens for Robono.",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"prepack": "npm run build && node ../../scripts/generate-sdk-file-sbom.mjs"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
|
-
"@robono/messaging": "^0.15.
|
|
60
|
+
"@robono/messaging": "^0.15.1",
|
|
61
61
|
"react": ">=18.2 <20",
|
|
62
62
|
"react-native": ">=0.76 <1",
|
|
63
63
|
"expo-audio": ">=55 <57",
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"expo-constants": ">=55 <57",
|
|
83
83
|
"@robono/location": "^0.4.1",
|
|
84
84
|
"expo-haptics": ">=55 <57",
|
|
85
|
-
"@robono/calling": "^0.6.
|
|
85
|
+
"@robono/calling": "^0.6.3",
|
|
86
86
|
"expo-media-library": ">=55 <57"
|
|
87
87
|
},
|
|
88
88
|
"license": "SEE LICENSE IN LICENSE",
|