@robono/messaging-react-native 0.20.1 → 0.20.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/README.md +5 -1
- package/SBOM.spdx.json +25 -25
- package/dist/expo-screen.js +24 -25
- package/dist/index.js +6 -6
- 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/recent-media.js +21 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## 0.20.2
|
|
2
|
+
|
|
3
|
+
- Match the original Messenger media viewer: Download, Delete, Forward, Share and Close, with no external Open action. Keep unavailable message actions disabled and preserve customer permission controls.
|
|
4
|
+
- Open the viewer immediately, use original-resolution photos with detailed zoom, tighten file/voice bubbles and quoted previews, and right-align attachment captions.
|
|
5
|
+
- Reuse bounded, authorized recent voice files for faster playback; explicit Download and Share always recheck access.
|
|
6
|
+
- Present the phone viewer immediately to prevent an iPhone close/reopen animation race.
|
|
7
|
+
|
|
1
8
|
## 0.18.0
|
|
2
9
|
|
|
3
10
|
## 0.20.1
|
package/README.md
CHANGED
|
@@ -160,7 +160,7 @@ The same React Native components support iOS and Android. Keyboard handling uses
|
|
|
160
160
|
|
|
161
161
|
## Recording and attachments with Expo
|
|
162
162
|
|
|
163
|
-
The optional `@robono/messaging-react-native/expo` entry supplies recording, review, voice playback and seeking, photo/video picking and preview, document selection, and private upload/download progress. Users explicitly send after review. A failed upload can retry with the same upload identity; cancelling removes the adapter's cache copy, never the original library item. Viewer copies are removed when the viewer closes. Managed voice and video play directly from private storage using native streaming. By default, `ExpoMessagingScreen` preloads up to six recent photos in the open conversation (2 MiB per file, 6 MiB total, two background transfers at a time). Custom adapters without streaming can also preload small
|
|
163
|
+
The optional `@robono/messaging-react-native/expo` entry supplies recording, review, voice playback and seeking, photo/video picking and preview, document selection, and private upload/download progress. Users explicitly send after review. A failed upload can retry with the same upload identity; cancelling removes the adapter's cache copy, never the original library item. Viewer copies are removed when the viewer closes. Managed voice and video play directly from private storage using native streaming. By default, `ExpoMessagingScreen` preloads up to six recent photos and voice clips in the open conversation (2 MiB per file, 6 MiB total, two background transfers at a time). Custom adapters without streaming can also preload small videos within those limits. Each transfer uses the authenticated storage adapter and counts as normal transfer usage. The cache is cleared when the app backgrounds, the conversation changes, access fails, or messages disappear; cached files require a fresh download on opening if their message has not been refreshed from the conversation history within 60 seconds. Cold voice/video streams and document downloads start on tap; an already authorized cached voice clip starts locally without waiting for another transfer. Explicit Download and Share always recheck current access. Set `preloadRecentMedia={false}` to keep all media transfers on demand. The recorder reserves 100 milliseconds at the duration limit for encoder padding; storage completion verifies the finished file. Recording stops when the app backgrounds or a call takes audio priority, leaving a review rather than sending automatically.
|
|
164
164
|
|
|
165
165
|
Install native dependencies with your Expo project's installer so their versions match your SDK:
|
|
166
166
|
|
|
@@ -585,3 +585,7 @@ does not grant access that the user's permissions deny.
|
|
|
585
585
|
## Existing Bridge friends
|
|
586
586
|
|
|
587
587
|
Open an already accepted external-app user ↔ Robono-user connection in the standard Messenger using the original connection ID and retained history. See [the Bridge Messenger guide](./BRIDGE-MESSENGER.md) and the included `examples/existing-bridge-chat.tsx`. This connector requires the matching core 0.13.0, server 0.32.0 and Expo 0.18.0 or web 0.17.0 release.
|
|
588
|
+
|
|
589
|
+
### Standard media viewer
|
|
590
|
+
|
|
591
|
+
Photos and videos use the same viewer: Download, Delete, Forward, Share and Close, subject to customer permissions. There is no external-player Open action. Photos use original files, support pinch/pan and tap-to-expand; video uses the native playback controls, seeking and fullscreen. Close remains available on expanded photos.
|
package/SBOM.spdx.json
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
"spdxVersion": "SPDX-2.3",
|
|
3
3
|
"dataLicense": "CC0-1.0",
|
|
4
4
|
"SPDXID": "SPDXRef-DOCUMENT",
|
|
5
|
-
"name": "@robono/messaging-react-native@0.20.
|
|
6
|
-
"documentNamespace": "https://robono.com/sbom/messaging-react-native/0.20.
|
|
5
|
+
"name": "@robono/messaging-react-native@0.20.2",
|
|
6
|
+
"documentNamespace": "https://robono.com/sbom/messaging-react-native/0.20.2/b1d130827b282ca0c6ff175011d031d1fb3f0329",
|
|
7
7
|
"creationInfo": {
|
|
8
|
-
"created": "2026-11-
|
|
8
|
+
"created": "2026-11-09T10:08:37.849Z",
|
|
9
9
|
"creators": [
|
|
10
10
|
"Organization: Robono (support@robono.com)"
|
|
11
11
|
]
|
|
@@ -14,11 +14,11 @@
|
|
|
14
14
|
{
|
|
15
15
|
"name": "@robono/messaging-react-native",
|
|
16
16
|
"SPDXID": "SPDXRef-Package",
|
|
17
|
-
"versionInfo": "0.20.
|
|
17
|
+
"versionInfo": "0.20.2",
|
|
18
18
|
"downloadLocation": "NOASSERTION",
|
|
19
19
|
"filesAnalyzed": true,
|
|
20
20
|
"packageVerificationCode": {
|
|
21
|
-
"packageVerificationCodeValue": "
|
|
21
|
+
"packageVerificationCodeValue": "b1d130827b282ca0c6ff175011d031d1fb3f0329"
|
|
22
22
|
},
|
|
23
23
|
"licenseConcluded": "LicenseRef-RobonoSDK",
|
|
24
24
|
"licenseDeclared": "LicenseRef-RobonoSDK",
|
|
@@ -55,11 +55,11 @@
|
|
|
55
55
|
"checksums": [
|
|
56
56
|
{
|
|
57
57
|
"algorithm": "SHA256",
|
|
58
|
-
"checksumValue": "
|
|
58
|
+
"checksumValue": "b022bc287a2c8cc651e44d66ed7c6042c8e2c9fa34a281238623ef0bdc837974"
|
|
59
59
|
},
|
|
60
60
|
{
|
|
61
61
|
"algorithm": "SHA1",
|
|
62
|
-
"checksumValue": "
|
|
62
|
+
"checksumValue": "f93c33000ec249f0791d6499b992a37910d00089"
|
|
63
63
|
}
|
|
64
64
|
],
|
|
65
65
|
"licenseConcluded": "LicenseRef-RobonoSDK",
|
|
@@ -93,11 +93,11 @@
|
|
|
93
93
|
"checksums": [
|
|
94
94
|
{
|
|
95
95
|
"algorithm": "SHA256",
|
|
96
|
-
"checksumValue": "
|
|
96
|
+
"checksumValue": "bd6b764454f3efbd7e961b203bfd871b4f5881ce20c86c362deb1b53ad879ef9"
|
|
97
97
|
},
|
|
98
98
|
{
|
|
99
99
|
"algorithm": "SHA1",
|
|
100
|
-
"checksumValue": "
|
|
100
|
+
"checksumValue": "5bf7011570e361ac68925dc47eabcc070f1d1120"
|
|
101
101
|
}
|
|
102
102
|
],
|
|
103
103
|
"licenseConcluded": "LicenseRef-RobonoSDK",
|
|
@@ -1214,11 +1214,11 @@
|
|
|
1214
1214
|
"checksums": [
|
|
1215
1215
|
{
|
|
1216
1216
|
"algorithm": "SHA256",
|
|
1217
|
-
"checksumValue": "
|
|
1217
|
+
"checksumValue": "c6d44c6562e568595339543105b7e9ad38b1be7748069986180459a41480419a"
|
|
1218
1218
|
},
|
|
1219
1219
|
{
|
|
1220
1220
|
"algorithm": "SHA1",
|
|
1221
|
-
"checksumValue": "
|
|
1221
|
+
"checksumValue": "82a6c4addcdfbc6bc88557b35e3c8a817789d7b4"
|
|
1222
1222
|
}
|
|
1223
1223
|
],
|
|
1224
1224
|
"licenseConcluded": "LicenseRef-RobonoSDK",
|
|
@@ -1784,11 +1784,11 @@
|
|
|
1784
1784
|
"checksums": [
|
|
1785
1785
|
{
|
|
1786
1786
|
"algorithm": "SHA256",
|
|
1787
|
-
"checksumValue": "
|
|
1787
|
+
"checksumValue": "5f4498b55731305d6c633cf5e4f97fa4c0a206948b5a73b6f3a141878ea04295"
|
|
1788
1788
|
},
|
|
1789
1789
|
{
|
|
1790
1790
|
"algorithm": "SHA1",
|
|
1791
|
-
"checksumValue": "
|
|
1791
|
+
"checksumValue": "0c8aba2c790206951341dc23039126541e26a41e"
|
|
1792
1792
|
}
|
|
1793
1793
|
],
|
|
1794
1794
|
"licenseConcluded": "LicenseRef-RobonoSDK",
|
|
@@ -1917,11 +1917,11 @@
|
|
|
1917
1917
|
"checksums": [
|
|
1918
1918
|
{
|
|
1919
1919
|
"algorithm": "SHA256",
|
|
1920
|
-
"checksumValue": "
|
|
1920
|
+
"checksumValue": "121c7d1c71c635c1ca0f9f6724c36021c3e72b3debd3c5e5e0d8d4e47d25a2af"
|
|
1921
1921
|
},
|
|
1922
1922
|
{
|
|
1923
1923
|
"algorithm": "SHA1",
|
|
1924
|
-
"checksumValue": "
|
|
1924
|
+
"checksumValue": "35754dc39a640f565ab1cc554030408c11af6cfe"
|
|
1925
1925
|
}
|
|
1926
1926
|
],
|
|
1927
1927
|
"licenseConcluded": "LicenseRef-RobonoSDK",
|
|
@@ -1936,11 +1936,11 @@
|
|
|
1936
1936
|
"checksums": [
|
|
1937
1937
|
{
|
|
1938
1938
|
"algorithm": "SHA256",
|
|
1939
|
-
"checksumValue": "
|
|
1939
|
+
"checksumValue": "6f58988cf3b095bb6268a7a5c9d62b7a61c286e6bff20072096e64c864dfcf03"
|
|
1940
1940
|
},
|
|
1941
1941
|
{
|
|
1942
1942
|
"algorithm": "SHA1",
|
|
1943
|
-
"checksumValue": "
|
|
1943
|
+
"checksumValue": "d1a48dd69ebf4ff69cc54ae23f9109e211242890"
|
|
1944
1944
|
}
|
|
1945
1945
|
],
|
|
1946
1946
|
"licenseConcluded": "LicenseRef-RobonoSDK",
|
|
@@ -2031,11 +2031,11 @@
|
|
|
2031
2031
|
"checksums": [
|
|
2032
2032
|
{
|
|
2033
2033
|
"algorithm": "SHA256",
|
|
2034
|
-
"checksumValue": "
|
|
2034
|
+
"checksumValue": "d9a7e8fa5bdbf6cc16e6779a2e396e72be0c2720e0fe69a289da0b4f32e8ac11"
|
|
2035
2035
|
},
|
|
2036
2036
|
{
|
|
2037
2037
|
"algorithm": "SHA1",
|
|
2038
|
-
"checksumValue": "
|
|
2038
|
+
"checksumValue": "6326194b15b6ec9d0983e042038ea2bc1098a3e6"
|
|
2039
2039
|
}
|
|
2040
2040
|
],
|
|
2041
2041
|
"licenseConcluded": "LicenseRef-RobonoSDK",
|
|
@@ -2050,11 +2050,11 @@
|
|
|
2050
2050
|
"checksums": [
|
|
2051
2051
|
{
|
|
2052
2052
|
"algorithm": "SHA256",
|
|
2053
|
-
"checksumValue": "
|
|
2053
|
+
"checksumValue": "74e4a4990fa5d06bda371cb0947e99a7d08b40d7c5888e6391929a242e28c29a"
|
|
2054
2054
|
},
|
|
2055
2055
|
{
|
|
2056
2056
|
"algorithm": "SHA1",
|
|
2057
|
-
"checksumValue": "
|
|
2057
|
+
"checksumValue": "6d5cca0974857842b7cbdd75ca7ca7ae5703c687"
|
|
2058
2058
|
}
|
|
2059
2059
|
],
|
|
2060
2060
|
"licenseConcluded": "LicenseRef-RobonoSDK",
|
|
@@ -2620,11 +2620,11 @@
|
|
|
2620
2620
|
"checksums": [
|
|
2621
2621
|
{
|
|
2622
2622
|
"algorithm": "SHA256",
|
|
2623
|
-
"checksumValue": "
|
|
2623
|
+
"checksumValue": "f4e6d66f082b4fdb41bb3659209b42da04e4bff5a823213b6372ab1a612844ea"
|
|
2624
2624
|
},
|
|
2625
2625
|
{
|
|
2626
2626
|
"algorithm": "SHA1",
|
|
2627
|
-
"checksumValue": "
|
|
2627
|
+
"checksumValue": "35e3404d6f6e5474a97c55ad8cb5fe8b8a5d4d12"
|
|
2628
2628
|
}
|
|
2629
2629
|
],
|
|
2630
2630
|
"licenseConcluded": "LicenseRef-RobonoSDK",
|
|
@@ -3494,11 +3494,11 @@
|
|
|
3494
3494
|
"checksums": [
|
|
3495
3495
|
{
|
|
3496
3496
|
"algorithm": "SHA256",
|
|
3497
|
-
"checksumValue": "
|
|
3497
|
+
"checksumValue": "44d2c6ff2b7b9ca3f0315b148f7557290eec84e7666b4b81f30ec0ed1f8cdcd7"
|
|
3498
3498
|
},
|
|
3499
3499
|
{
|
|
3500
3500
|
"algorithm": "SHA1",
|
|
3501
|
-
"checksumValue": "
|
|
3501
|
+
"checksumValue": "621532549004ab4b0d58a298e3adfd756496df6e"
|
|
3502
3502
|
}
|
|
3503
3503
|
],
|
|
3504
3504
|
"licenseConcluded": "LicenseRef-RobonoSDK",
|
package/dist/expo-screen.js
CHANGED
|
@@ -121,7 +121,7 @@ function VoicePlayer({ file, audio, design, inline, draft, autoPlay = false }) {
|
|
|
121
121
|
// Native file loading and audio-session preparation are independent. Start
|
|
122
122
|
// both now; playback still requires both and an active app.
|
|
123
123
|
const begin = () => {
|
|
124
|
-
if (!scope.alive || recovered.current || !autoPlay || started || cancelled || !scope.release || !player.isLoaded)
|
|
124
|
+
if (!scope.alive || recovered.current || !autoPlay || started || cancelled || !scope.release || (!player.isLoaded && (Platform.OS !== 'android' || !!file.resumeAtMs)))
|
|
125
125
|
return;
|
|
126
126
|
if (AppState.currentState !== 'active' || audio.isAvailable?.() === false) {
|
|
127
127
|
void stop();
|
|
@@ -129,7 +129,6 @@ function VoicePlayer({ file, audio, design, inline, draft, autoPlay = false }) {
|
|
|
129
129
|
}
|
|
130
130
|
started = true;
|
|
131
131
|
autoPreparing = false;
|
|
132
|
-
clearTimeout(startupTimeout);
|
|
133
132
|
void (async () => { if (file.resumeAtMs)
|
|
134
133
|
await player.seekTo(file.resumeAtMs / 1000); if (!scope.alive || cancelled || AppState.currentState !== 'active')
|
|
135
134
|
return; playIntent.current = true; player.play(); setPlaying(player.playing); })().catch(e => { if (!recoverStream())
|
|
@@ -181,6 +180,7 @@ function VoicePlayer({ file, audio, design, inline, draft, autoPlay = false }) {
|
|
|
181
180
|
setPosition(player.currentTime * 1000);
|
|
182
181
|
setPlaying(player.playing);
|
|
183
182
|
if (!reported && player.playing && player.currentTime > 0) {
|
|
183
|
+
clearTimeout(startupTimeout);
|
|
184
184
|
reported = true;
|
|
185
185
|
mediaReady('audio-playing', file.uri);
|
|
186
186
|
}
|
|
@@ -207,8 +207,8 @@ function VoicePlayer({ file, audio, design, inline, draft, autoPlay = false }) {
|
|
|
207
207
|
await releaseVoice(scope);
|
|
208
208
|
}
|
|
209
209
|
else {
|
|
210
|
-
if (!player.isLoaded)
|
|
211
|
-
|
|
210
|
+
if (!player.isLoaded && Platform.OS !== 'android')
|
|
211
|
+
return;
|
|
212
212
|
await stopVoicePlayers();
|
|
213
213
|
if (!await acquireVoice(scope, audio))
|
|
214
214
|
return;
|
|
@@ -216,7 +216,7 @@ function VoicePlayer({ file, audio, design, inline, draft, autoPlay = false }) {
|
|
|
216
216
|
await releaseVoice(scope);
|
|
217
217
|
return;
|
|
218
218
|
}
|
|
219
|
-
if (player.currentTime >= player.duration - .05)
|
|
219
|
+
if (player.duration > 0 && player.currentTime >= player.duration - .05)
|
|
220
220
|
await player.seekTo(0);
|
|
221
221
|
playIntent.current = true;
|
|
222
222
|
player.play();
|
|
@@ -236,7 +236,7 @@ function VoicePlayer({ file, audio, design, inline, draft, autoPlay = false }) {
|
|
|
236
236
|
const duration = file.durationMs ?? player.duration * 1000;
|
|
237
237
|
if (draft)
|
|
238
238
|
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())
|
|
239
|
+
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
240
|
setError(uiText("Could not seek. Try again.")); }); } });
|
|
241
241
|
}
|
|
242
242
|
function VideoPlayer({ file, audio }) {
|
|
@@ -323,16 +323,7 @@ function FileViewer({ file, kind, audio, design }) {
|
|
|
323
323
|
return _jsx(VideoPlayer, { file: file, audio: audio, design: design });
|
|
324
324
|
if (kind === 'image')
|
|
325
325
|
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 })] });
|
|
326
|
+
return _jsx(ExpoDocumentPreview, { file: file });
|
|
336
327
|
}
|
|
337
328
|
export function MessagingMediaOverlay({ controller, audio, appearance, inlineVoice = false, inlineRecorder = false, viewerActions, onDismiss, onDownloadAttachment, mediaViewer, onDocumentLink }) {
|
|
338
329
|
const { text: uiText } = useRobonoLocale();
|
|
@@ -395,9 +386,10 @@ export function MessagingMediaOverlay({ controller, audio, appearance, inlineVoi
|
|
|
395
386
|
if ((typeof inlineVoice === 'function' ? inlineVoice() : inlineVoice) && state.kind === 'voice' && ['opening', 'viewing', 'failed'].includes(state.phase) && !review)
|
|
396
387
|
return null;
|
|
397
388
|
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
|
-
|
|
389
|
+
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;
|
|
390
|
+
// Present immediately: an iOS fade can still be dismissing when another attachment
|
|
391
|
+
// opens, leaving the next native modal invisible. Safe area belongs to this window.
|
|
392
|
+
return _jsx(Modal, { transparent: true, visible: state.phase !== 'idle' && state.phase !== 'choosing', onDismiss: onDismiss, animationType: "none", onRequestClose: () => { if (expanded)
|
|
401
393
|
setExpanded(false);
|
|
402
394
|
else
|
|
403
395
|
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() })] }) })) }) }) }) });
|
|
@@ -550,11 +542,18 @@ function ExpoMessagingScreenContent({ storage, audioSession, renderConversation,
|
|
|
550
542
|
void Haptics.selectionAsync().catch(() => { }); }, []);
|
|
551
543
|
const defaultCopyText = useCallback(async (text) => { await Clipboard.setStringAsync(text); }, []);
|
|
552
544
|
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
|
|
545
|
+
const openAttachment = useCallback(async (m) => {
|
|
546
|
+
const intent = ++openingIntent.current;
|
|
547
|
+
opened.current = { messageId: m.id, kind: m.kind, started: Date.now(), reported: new Set() };
|
|
548
|
+
message.current = m;
|
|
549
|
+
await controller.open(m, async () => {
|
|
550
|
+
await stopVoicePlayers();
|
|
551
|
+
if (intent !== openingIntent.current)
|
|
552
|
+
return undefined;
|
|
553
|
+
const draft = m.media && m.kind !== 'text' && m.kind !== 'poll' ? await restore(m.media, m.kind) : undefined;
|
|
554
|
+
return draft ? copyMessagingCache(draft) : undefined;
|
|
555
|
+
});
|
|
556
|
+
}, [restore, controller]);
|
|
558
557
|
const screenProps = { ...props, requestedMessageAction,
|
|
559
558
|
onQuoteReady: props.onQuoteReady ?? defaultQuoteReady,
|
|
560
559
|
copyText: props.copyText ?? defaultCopyText,
|
|
@@ -612,7 +611,7 @@ function ExpoMessagingScreenContent({ storage, audioSession, renderConversation,
|
|
|
612
611
|
afterViewer.current = { kind, messageId: m.id, sequence: Date.now() };
|
|
613
612
|
void controller.cancel().then(() => {
|
|
614
613
|
// Some installed native runtimes omit onDismiss after a media modal closes.
|
|
615
|
-
// Keep the normal event fast path;
|
|
614
|
+
// Keep the normal event fast path; retain a recovery delay for older native runtimes.
|
|
616
615
|
// Navigation/unmount clears the queued action, so it cannot open in another chat.
|
|
617
616
|
if (afterViewer.current)
|
|
618
617
|
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');
|
|
@@ -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/recent-media.js
CHANGED
|
@@ -14,9 +14,28 @@ export class RecentMessagingMedia {
|
|
|
14
14
|
}
|
|
15
15
|
storage = {
|
|
16
16
|
thumbnail: (message, context) => this.source.thumbnail?.(message, context) ?? Promise.resolve(null),
|
|
17
|
-
stream: (message, context) =>
|
|
17
|
+
stream: async (message, context) => {
|
|
18
|
+
if (context.signal.aborted)
|
|
19
|
+
throw Error('Cancelled.');
|
|
20
|
+
const id = key(message), entry = this.entries.get(id);
|
|
21
|
+
// An already authorized original starts locally. Never wait behind a
|
|
22
|
+
// speculative transfer: a cold tap keeps the normal streaming path.
|
|
23
|
+
if (entry?.file && entry.expires > this.now()) {
|
|
24
|
+
const copy = await this.files.copy(entry.file);
|
|
25
|
+
if (context.signal.aborted || this.entries.get(id) !== entry) {
|
|
26
|
+
await this.files.remove(copy);
|
|
27
|
+
throw Error('Cancelled.');
|
|
28
|
+
}
|
|
29
|
+
return copy;
|
|
30
|
+
}
|
|
31
|
+
if (entry?.file)
|
|
32
|
+
this.drop(id, entry);
|
|
33
|
+
return this.source.stream?.(message, context) ?? null;
|
|
34
|
+
},
|
|
18
35
|
upload: (file, context) => this.source.upload(file, context), discard: id => this.source.discard(id),
|
|
19
36
|
download: async (message, context) => {
|
|
37
|
+
if (context.reauthorize)
|
|
38
|
+
return this.source.download(message, context);
|
|
20
39
|
const id = key(message), entry = this.entries.get(id);
|
|
21
40
|
if (!entry)
|
|
22
41
|
return this.source.download(message, context);
|
|
@@ -57,7 +76,7 @@ export class RecentMessagingMedia {
|
|
|
57
76
|
if (wanted.size >= 6)
|
|
58
77
|
break;
|
|
59
78
|
const size = m.media?.byteSize;
|
|
60
|
-
if (this.source.stream &&
|
|
79
|
+
if (this.source.stream && m.kind === 'video')
|
|
61
80
|
continue;
|
|
62
81
|
if (m.deleted || !['image', 'voice', 'video'].includes(m.kind) || !size || size > 2 * 1048576 || bytes + size > 6 * 1048576)
|
|
63
82
|
continue;
|