@robono/messaging-react-native 0.18.0 → 0.20.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.
@@ -1,12 +1,14 @@
1
1
  # Existing Bridge friends in the standard Messenger
2
2
 
3
- Required versions: `@robono/messaging` **0.13.0**, `@robono/server` **0.32.0**, and `@robono/messaging-react-native` **0.18.0** (Expo) or `@robono/messaging-web` **0.17.0** (web). Use `@robono/location` **0.4.1** for the screen package's shared appearance helpers; this does not enable Maps or location access.
3
+ Bridge language integration — November 9, 2026. This guide covers the package versions below.
4
4
 
5
- Server: `npm install @robono/server@0.32.0`
5
+ Required versions: `@robono/messaging` **0.15.0**, `@robono/server` **0.34.0**, and `@robono/messaging-react-native` **0.20.0** (Expo) or `@robono/messaging-web` **0.19.0** (web). Use `@robono/location` **0.4.1** for the screen package's shared appearance helpers; this does not enable Maps or location access.
6
6
 
7
- Expo: `npm install @robono/messaging@0.13.0 @robono/messaging-react-native@0.18.0 @robono/location@0.4.1`
7
+ Server: `npm install @robono/server@0.34.0`
8
8
 
9
- Web: `npm install @robono/messaging@0.13.0 @robono/messaging-web@0.17.0 @robono/location@0.4.1`
9
+ Expo: `npm install @robono/messaging@0.15.0 @robono/messaging-react-native@0.20.0 @robono/location@0.4.1`
10
+
11
+ Web: `npm install @robono/messaging@0.15.0 @robono/messaging-web@0.19.0 @robono/location@0.4.1`
10
12
 
11
13
  The Expo integration uses the existing supported Expo 55/56 native dependencies. This connector adds no new native dependency. Keep the host's existing supported peers and native configuration. The service endpoint is `https://api.robono.com/v1/bridge/messenger`; a 404 there means the service route is not deployed yet, not that a replacement friend must be created.
12
14
 
@@ -59,8 +61,67 @@ The durable wake covers message creation/change/deletion, receipt changes and co
59
61
 
60
62
  This release does not invent unsupported Bridge reactions, threaded replies, polls, groups, scheduled sends or presence. Their controls remain unavailable in these direct Bridge chats. Delivery/read/heard receipts retain their existing meanings; a heard receipt is not a new claim of complete playback. The separate online-status, phrase-detection and detailed playback-event requests require their own contracts and are not enabled by this connector.
61
63
 
64
+ ## Translation and transcripts
65
+
66
+ The same standard Expo and web screens offer:
67
+
68
+ | Original message | Available result |
69
+ | --- | --- |
70
+ | Text | Translated text or spoken translation |
71
+ | Voice message | Written transcript; translated text or spoken translation |
72
+ | Video with speech | Written transcript; translated text or spoken translation |
73
+
74
+ Spoken translation reads the translated words aloud in the standard Messenger voice player. It does not dub a video or burn subtitles into it. The original recording/video remains available through **Show original**. Recordings and videos must be at most 20 MB and one hour; a silent video has no speech to transcribe. Spoken output supports up to 4,000 translated characters per message; longer results remain available as text and no speech-generation charge is authorized.
75
+
76
+ Enable **Transcription** and/or **Translation** in the existing website feature choices. Friend permissions still apply: `speech.stt.allowed` permits speech processing, `speech.stt.deliver_transcript` permits showing its transcript, and `speech.translation.allowed` plus `deliver_translated_text` permit translated text. Translating voice/video also requires speech processing. The website cannot override a friend restriction. Supply the friend's known language through `contact.language` or let the person choose it in Translation settings. The destination language and text/voice choice are saved per friend. To offer voice output, also enable **Spoken translations** in appearance settings. The friend must permit `speech.tts.allowed` and `speech.translation.deliver_translated_audio` as well as translated text. Network restrictions and a host’s `languageTools.voiceOutput: false` still take precedence.
77
+
78
+ The factories now connect these operations automatically. Keep using `createExpoBridgeMessenger` / `createWebBridgeMessenger` and the supplied screen; no custom translation UI or transport is needed. The underlying public operation is `client.transform(messageId, 'transcript' | 'translation', targetLanguage, 'text' | 'voice', {signal, sourceLanguage})`.
79
+
80
+ ### Approve costs on the customer's server
81
+
82
+ Add `authorizeCost` to the existing backend adapter. It receives the authenticated actor, connection, operation and a trusted `quote`. Return `true` only when the customer's policy approves the maximum cost. An absent callback blocks new processing; returning `false` declines it. The callback also runs for a zero-cost quote so a test or complimentary plan never bypasses the customer's policy.
83
+
84
+ ```ts
85
+ const route = createBridgeMessengerBackendAdapter({
86
+ apiKey: process.env.ROBONO_SERVER_KEY!,
87
+ authenticate: verifyExistingSession,
88
+ authorize: checkCurrentFriendPermission,
89
+ authorizeCost: async ({actorId, connectionId, quote, request}) => {
90
+ return approveLanguageBudget({
91
+ actorId, connectionId,
92
+ stage: quote.stage,
93
+ maximumUsdMicros: quote.maximumChargeMicros,
94
+ signal: request.signal,
95
+ });
96
+ },
97
+ });
98
+ ```
99
+
100
+ `approveLanguageBudget` is the customer's own policy function, not a Robono export. Do not copy a callback that always returns `true` unless unrestricted spending is the intended policy. Resolve per-user spending rules on the server; device-supplied prices and approval tokens are ignored.
101
+
102
+ A voice/video translation has two approvals for text output and a third for voice output:
103
+
104
+ 1. Robono reads the real recording duration without transcribing it. The callback approves **transcription** for that duration.
105
+ 2. After the transcript is saved, Robono quotes **translation** for the exact input character count. The callback approves that amount before translation begins.
106
+
107
+ 3. For voice output, Robono quotes **speech** for the exact translated character count before generating the recording. Text-message spoken translation uses only steps 2 and 3.
108
+
109
+ This avoids guessing either text length. If a later step is declined or cancelled, earlier completed processing remains saved and can still be charged. A retry reuses those results. Saved results require fresh permissions but no new processing approval or processing charge. Changes to the original message or source-language choice produce a new result rather than reusing the wrong one.
110
+
111
+ Use `quote.maximumChargeMicros` to approve the maximum for that stage; divide by 1,000,000 for dollars. It is a ceiling before applicable included usage/discounts, not a promise that the full amount will be charged. Stages are `transcription`, `translation` and `speech`; their metrics are `transcription_ms`, `translation_character` and `speech_character`. `metric`, `quantity`, `unitAmountMicros` and `unitQuantity` describe the rate. `billingModel` distinguishes `measured_usage`, legacy `fixed_unit`, `complimentary` and `sandbox`. Do not assume every plan has a fixed per-message price.
112
+
113
+ ### Identify the actual current plan
114
+
115
+ From the customer server, call `await robono.usage()` with an API key allowed to read billing. Its new `contract` field contains `available`, `planKey`, `catalogVersion`, `billingModel` and `languageRates`. This is the account's current agreement, including a retained legacy fixed-price agreement; the public pricing catalog is not proof of that account's plan. If `contract.available` is false, show that billing setup needs attention and decline processing. Never fall back to an assumed old price.
116
+
117
+ The quote returned for each request is authoritative. Robono rechecks the plan, rate, permissions and spending limit before starting work. A price change requires a new approval. Repeating a completed request does not charge twice, including when its response was lost.
118
+
119
+ ### Cancellation and retained results
120
+
121
+ The standard bubble shows **Cancel** while processing. Custom hosts may pass an `AbortSignal` to `client.transform`. Cancellation stops subsequent stages and prevents a late result from appearing. It cannot undo a stage that already completed. Results stay attached to the original retained Bridge message; they do not create another conversation or another message. Deleting, expiring or denying access to the original also prevents reading its saved result. Saved audio uses a short-lived playback link. Reopening it checks access and issues a fresh link without generating or charging for speech again; normal media delivery charges still follow the customer’s plan. Audio does not outlive the source message’s retention period.
122
+
62
123
  ## Release requirements
63
124
 
64
- Release together: migration `20261108040000_standard_bridge_messenger.sql`, function `external-app-bridge-messenger`, API router `/v1/bridge/messenger`, and core/server/Expo/web packages. Verify deployment before publishing supported install versions. Website/API uploads remain owner-operated.
125
+ Release together: migrations `20261108040000_standard_bridge_messenger.sql` , `20261108060000_bridge_language_authorization.sql` and `20261109010000_bridge_spoken_translation.sql`, functions `external-app-bridge-messenger` and `external-app-usage`, and the speech worker duration endpoint, API router `/v1/bridge/messenger`, and core/server/Expo/web packages. Verify deployment before publishing supported install versions. Website/API uploads remain owner-operated.
65
126
 
66
127
  Local verification uses synthetic accepted Bridge connections in an isolated service, through the public adapter and standard screens. iPhone and Android checks cover photo, video, document and voice upload/send/download, thumbnails, native voice playback, changing permissions and revoked access. Browser checks cover opening retained history and sending through the standard composer. Service checks cover original IDs, pagination, private access, duplicate prevention after a lost response and recovery after a missed notification. This is not a claim that a new push notification was delivered through Apple's or Google's service in this check.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## 0.18.0
2
2
 
3
+ ## 0.20.0
4
+
5
+ - Existing Bridge conversations support spoken translations of text, voice messages and video speech through the standard Messenger. Each new processing stage requires server cost approval; saved audio retains permission and expiry checks.
6
+
3
7
  Adds the standard Expo Bridge connector, original-message read receipts, retained history and shared attachment handling.
4
8
 
5
9
  ## Unreleased
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.18.0",
6
- "documentNamespace": "https://robono.com/sbom/messaging-react-native/0.18.0/85ab817f88a6761353ea3e720210dbb6625a0524",
5
+ "name": "@robono/messaging-react-native@0.20.0",
6
+ "documentNamespace": "https://robono.com/sbom/messaging-react-native/0.20.0/a61e0fc855b40176420daec8025eaf2885f9bd22",
7
7
  "creationInfo": {
8
- "created": "2026-11-08T17:19:29.305Z",
8
+ "created": "2026-11-09T06:07:50.921Z",
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.18.0",
17
+ "versionInfo": "0.20.0",
18
18
  "downloadLocation": "NOASSERTION",
19
19
  "filesAnalyzed": true,
20
20
  "packageVerificationCode": {
21
- "packageVerificationCodeValue": "85ab817f88a6761353ea3e720210dbb6625a0524"
21
+ "packageVerificationCodeValue": "a61e0fc855b40176420daec8025eaf2885f9bd22"
22
22
  },
23
23
  "licenseConcluded": "LicenseRef-RobonoSDK",
24
24
  "licenseDeclared": "LicenseRef-RobonoSDK",
@@ -26,7 +26,7 @@
26
26
  "LicenseRef-RobonoSDK"
27
27
  ],
28
28
  "copyrightText": "Copyright (c) 2026 Add to Loop LLC.",
29
- "comment": "Host-supplied peers (not bundled): {\"@robono/messaging\":\"^0.13.0\",\"react\":\">=18.2 <20\",\"react-native\":\">=0.76 <1\",\"expo-audio\":\">=55 <57\",\"expo-image-picker\":\">=55 <57\",\"expo-document-picker\":\">=55 <57\",\"expo-file-system\":\">=55.0.5 <57\",\"expo-sharing\":\">=55 <57\",\"expo-video\":\">=55 <57\",\"expo-crypto\":\">=55 <57\",\"react-native-safe-area-context\":\">=5 <6\",\"react-native-svg\":\">=15 <16\",\"@robono/calling-react-native\":\"^0.9.3\",\"expo-clipboard\":\">=8 <57\",\"expo-image-manipulator\":\">=14 <57\",\"expo-video-thumbnails\":\">=14 <57\",\"react-native-webview\":\">=13 <14\",\"expo-blur\":\">=55 <57\",\"expo-notifications\":\">=55 <57\",\"expo-secure-store\":\">=55 <57\",\"@robono/location-react-native\":\"^0.4.1\",\"expo-location\":\">=55 <57\",\"expo-constants\":\">=55 <57\",\"@robono/location\":\"^0.4.1\",\"expo-haptics\":\">=55 <57\",\"@robono/calling\":\"^0.6.2\",\"expo-media-library\":\">=55 <57\"}"
29
+ "comment": "Host-supplied peers (not bundled): {\"@robono/messaging\":\"^0.15.0\",\"react\":\">=18.2 <20\",\"react-native\":\">=0.76 <1\",\"expo-audio\":\">=55 <57\",\"expo-image-picker\":\">=55 <57\",\"expo-document-picker\":\">=55 <57\",\"expo-file-system\":\">=55.0.5 <57\",\"expo-sharing\":\">=55 <57\",\"expo-video\":\">=55 <57\",\"expo-crypto\":\">=55 <57\",\"react-native-safe-area-context\":\">=5 <6\",\"react-native-svg\":\">=15 <16\",\"@robono/calling-react-native\":\"^0.9.3\",\"expo-clipboard\":\">=8 <57\",\"expo-image-manipulator\":\">=14 <57\",\"expo-video-thumbnails\":\">=14 <57\",\"react-native-webview\":\">=13 <14\",\"expo-blur\":\">=55 <57\",\"expo-notifications\":\">=55 <57\",\"expo-secure-store\":\">=55 <57\",\"@robono/location-react-native\":\"^0.4.1\",\"expo-location\":\">=55 <57\",\"expo-constants\":\">=55 <57\",\"@robono/location\":\"^0.4.1\",\"expo-haptics\":\">=55 <57\",\"@robono/calling\":\"^0.6.2\",\"expo-media-library\":\">=55 <57\"}"
30
30
  }
31
31
  ],
32
32
  "files": [
@@ -36,11 +36,11 @@
36
36
  "checksums": [
37
37
  {
38
38
  "algorithm": "SHA256",
39
- "checksumValue": "4a365b01b97e227f46ea6b5dae0fe5de4bd97002a76c82348ddab0d57b4e0c63"
39
+ "checksumValue": "a3b88b9e419af1002ae5b58c0078df79f1fb2d4e4f7d5934c79673f7cac48c8f"
40
40
  },
41
41
  {
42
42
  "algorithm": "SHA1",
43
- "checksumValue": "dc6e5aefe795c90c4426a6c1be2eb8fcd202b033"
43
+ "checksumValue": "51f781789ff11bb032a46da289d9f6eb00b1677c"
44
44
  }
45
45
  ],
46
46
  "licenseConcluded": "LicenseRef-RobonoSDK",
@@ -55,11 +55,11 @@
55
55
  "checksums": [
56
56
  {
57
57
  "algorithm": "SHA256",
58
- "checksumValue": "a6acf66a7d77df6d8c0f9bb6f3ab646bd30102d0d22c2be6c8afa1a7b960de87"
58
+ "checksumValue": "ec9ba9cac621c90b8c8e7a19ed4f03a582fdda43a5173ebdd0b159584fa1f00d"
59
59
  },
60
60
  {
61
61
  "algorithm": "SHA1",
62
- "checksumValue": "c76adb2fb12ffc27e461535289f33ef8deaf4148"
62
+ "checksumValue": "77096aea33f08af50256327bf6154ce36220ba1f"
63
63
  }
64
64
  ],
65
65
  "licenseConcluded": "LicenseRef-RobonoSDK",
@@ -720,11 +720,11 @@
720
720
  "checksums": [
721
721
  {
722
722
  "algorithm": "SHA256",
723
- "checksumValue": "1bc33a14bd9a28349ed98e4600db94dce428218969bdf21154a841558d7b9ff6"
723
+ "checksumValue": "a26aaba16918fb2169259f5b71ae7c88ad2092e65be08247ec7d2f4c868d1255"
724
724
  },
725
725
  {
726
726
  "algorithm": "SHA1",
727
- "checksumValue": "1856aa5713eca543119759dbb27e9a135ed0ce86"
727
+ "checksumValue": "f996763b4ace926c2ff6b384b58c9c2f2994c871"
728
728
  }
729
729
  ],
730
730
  "licenseConcluded": "LicenseRef-RobonoSDK",
@@ -1784,11 +1784,11 @@
1784
1784
  "checksums": [
1785
1785
  {
1786
1786
  "algorithm": "SHA256",
1787
- "checksumValue": "faf18c4434b5ccd1c70cd50f7605d01dfd9cefd6490168f768ac41d0709c9818"
1787
+ "checksumValue": "49ae7826d25981156e462d703b586d956fe32f318324e039d0ff85d5dd77097c"
1788
1788
  },
1789
1789
  {
1790
1790
  "algorithm": "SHA1",
1791
- "checksumValue": "a3da1ebc787f98e8f5951d6d45d8d9fa876f52c3"
1791
+ "checksumValue": "3da96a9bb9c7541c76d272d85518b7af65d5e43e"
1792
1792
  }
1793
1793
  ],
1794
1794
  "licenseConcluded": "LicenseRef-RobonoSDK",
@@ -3494,11 +3494,11 @@
3494
3494
  "checksums": [
3495
3495
  {
3496
3496
  "algorithm": "SHA256",
3497
- "checksumValue": "8af37fac8091c00c619fc3a3de25b8517d36093211e87ce13e5ccc9a7bdc9219"
3497
+ "checksumValue": "e9eba1648260083fe7d1d51ab904926bf6d33c89f1c0aaf35bb8ee3cb9f8af15"
3498
3498
  },
3499
3499
  {
3500
3500
  "algorithm": "SHA1",
3501
- "checksumValue": "d9f1cd9609ae0676734291ef2d022520b9454c00"
3501
+ "checksumValue": "4aecd0aca3c5ccdd32e087e3cda2716935143ca9"
3502
3502
  }
3503
3503
  ],
3504
3504
  "licenseConcluded": "LicenseRef-RobonoSDK",
@@ -1,10 +1,10 @@
1
- import { bridgeMessengerFetch, refreshBridgeMessengerFromPush } from '@robono/messaging';
1
+ import { bridgeMessengerFetch, bridgeLanguageRequest, createMessagingTransport, refreshBridgeMessengerFromPush } from '@robono/messaging';
2
2
  import { createExpoMessagingClient, expoOutbox } from './expo-outbox.js';
3
3
  import { createExpoMessagingStorage, createExpoMessagingAudioSession } from './expo-media.js';
4
4
  /** Standard ExpoMessagingScreen connection for an already accepted Bridge friend. */
5
5
  export function createExpoBridgeMessenger(options) {
6
6
  const transportFetch = bridgeMessengerFetch(options.connectionId, options.fetch);
7
- const client = createExpoMessagingClient({ ...options, fetch: transportFetch, namespace: (options.namespace ?? '') + ':bridge:' + options.connectionId });
7
+ const client = createExpoMessagingClient({ ...options, fetch: transportFetch, transformRequest: bridgeLanguageRequest(createMessagingTransport({ ...options, fetch: transportFetch })), namespace: (options.namespace ?? '') + ':bridge:' + options.connectionId });
8
8
  const storage = createExpoMessagingStorage({ url: options.url, getAccessToken: options.getAccessToken, fetch: transportFetch });
9
9
  const outgoing = expoOutbox(client);
10
10
  if (outgoing)
package/dist/index.js CHANGED
@@ -168,7 +168,7 @@ function MessagingProviderContent({ children, ...props }) {
168
168
  const design = useMemo(() => localizeMessagingAppearance(messagingScreenAppearance(effectiveAppearance, styleScreen), uiText), [effectiveAppearance, styleScreen, uiText]);
169
169
  const messagingPopupColors = useMessagingPopupColors(design);
170
170
  const linkHandling = useMemo(() => ({ ...props.linkHandling, webLinks: props.linkHandling?.webLinks !== false && effectiveAppearance.linkHandling?.webLinks !== false, addresses: props.linkHandling?.addresses !== false && effectiveAppearance.linkHandling?.addresses !== false }), [props.linkHandling, effectiveAppearance.linkHandling]);
171
- const languageTools = useMemo(() => ({ ...props.languageTools, voiceOutput: props.languageTools?.voiceOutput !== false && effectiveAppearance.spokenTranslations !== false }), [props.languageTools, effectiveAppearance.spokenTranslations]);
171
+ const languageTools = useMemo(() => ({ ...props.languageTools, voiceOutput: state.translationVoiceAvailable !== false && props.languageTools?.voiceOutput !== false && effectiveAppearance.spokenTranslations !== false }), [props.languageTools, effectiveAppearance.spokenTranslations, state.translationVoiceAvailable]);
172
172
  // Resolve the device zone once per provider render, not once per bubble.
173
173
  // The formatter is recreated when the locale or zone changes, so resuming
174
174
  // after travel keeps the same local-time behavior without rebuilding it for
@@ -394,6 +394,18 @@ function selectBubbleUI(context, props, previous) {
394
394
  selected.state = previous.state;
395
395
  return previous && Object.keys(selected).every(key => Object.is(selected[key], previous[key])) ? previous : selected;
396
396
  }
397
+ function languageFailure(error) {
398
+ const messages = { language_cost_authorization_required: "Your app needs to finish setting up language tools. Please contact support.", language_cost_declined: "This language request was not approved.", source_language_required: "Choose your friend’s message language in Translation settings.", transcription_size_limit: "This recording is too large to transcribe. The limit is 20 MB.", empty_transcript: "No spoken words were found in this message.", language_price_changed: "The price changed. Please try again." };
399
+ if (error instanceof MessagingError) {
400
+ if (messages[error.code ?? ''])
401
+ return messages[error.code ?? ''];
402
+ if (error.status === 402)
403
+ return 'This language request could not be approved. Check your plan or spending limit.';
404
+ if ([401, 403].includes(error.status))
405
+ return 'This language tool is no longer allowed.';
406
+ }
407
+ return 'This message could not be converted. Try again.';
408
+ }
397
409
  export function MessagingBubble(props) {
398
410
  const context = useMessagingUI(), last = useRef(null);
399
411
  const selected = selectBubbleUI(context, props, last.current);
@@ -432,11 +444,11 @@ const MessagingBubbleView = React.memo(function MessagingBubbleView({ message, p
432
444
  });
433
445
  const [transformed, setTransformed] = useState(null), [transforming, setTransforming] = useState(false), [showOriginal, setShowOriginal] = useState(false), [translationAutoPlay, setTranslationAutoPlay] = useState(false);
434
446
  const TranslationVoice = components?.TranslationVoice;
435
- const canTranscript = languageTools?.transcription !== false && !pendingStatus && voice && !!state.settings?.features.transcription && client.hasLanguageTools() && !message.deleted;
447
+ const canTranscript = languageTools?.transcription !== false && !pendingStatus && (voice || message.kind === 'video') && !!state.settings?.features.transcription && client.hasLanguageTools() && !message.deleted;
436
448
  const translation = state.translationPreference;
437
449
  const translationLanguage = translation?.language ?? languageTools?.preferredLanguage ?? language;
438
450
  const sourceLanguage = participants?.[message.senderId]?.language ?? (state.conversation?.kind === 'direct' ? contact.language : undefined) ?? translation?.sourceLanguage;
439
- const canTranslate = languageTools?.translation !== false && !mine && !extra?.weather && !extra?.call && !pendingStatus && ['text', 'voice'].includes(message.kind) && !!state.settings?.enabled && !!state.settings.features.translation && client.hasLanguageTools() && !message.deleted && translation?.mode !== undefined && translation.mode !== 'off' && needsMessageTranslation(sourceLanguage, translationLanguage) && (translation.mode !== 'voice' || languageTools?.voiceOutput === false || !!TranslationVoice);
451
+ const canTranslate = languageTools?.translation !== false && !mine && !extra?.weather && !extra?.call && !pendingStatus && ['text', 'voice', 'video'].includes(message.kind) && !!state.settings?.enabled && !!state.settings.features.translation && client.hasLanguageTools() && !message.deleted && translation?.mode !== undefined && translation.mode !== 'off' && needsMessageTranslation(sourceLanguage, translationLanguage) && (translation.mode !== 'voice' || languageTools?.voiceOutput === false || !!TranslationVoice);
440
452
  const transformGeneration = useRef(0), transformAbort = useRef(null);
441
453
  useEffect(() => { transformAbort.current?.abort(); transformGeneration.current++; setTransformed(null); setTransforming(false); setShowOriginal(false); setTranslationAutoPlay(false); return () => { transformAbort.current?.abort(); transformGeneration.current++; }; }, [message.id, message.deleted, message.text, message.media?.assetId, translationLanguage, translation?.mode, sourceLanguage, state.settings?.enabled, state.settings?.features.transcription, state.settings?.features.translation, languageTools?.translation, languageTools?.transcription, languageTools?.voiceOutput, languageTools?.revision]);
442
454
  useEffect(() => { if (!transformed?.audio)
@@ -446,7 +458,7 @@ const MessagingBubbleView = React.memo(function MessagingBubbleView({ message, p
446
458
  return;
447
459
  } if (transforming)
448
460
  return; const generation = ++transformGeneration.current, controller = transformAbort.current = new AbortController(); setTransforming(true); setActions(false); setError(''); try {
449
- const result = await client.transform(message.id, kind, translationLanguage ?? Intl.DateTimeFormat().resolvedOptions().locale, output, { signal: controller.signal });
461
+ const result = await client.transform(message.id, kind, translationLanguage ?? Intl.DateTimeFormat().resolvedOptions().locale, output, { signal: controller.signal, sourceLanguage: sourceLanguage ?? undefined });
450
462
  if (generation === transformGeneration.current) {
451
463
  setTransformed(result);
452
464
  setShowOriginal(false);
@@ -455,7 +467,7 @@ const MessagingBubbleView = React.memo(function MessagingBubbleView({ message, p
455
467
  }
456
468
  catch (e) {
457
469
  if (generation === transformGeneration.current && !controller.signal.aborted)
458
- setError(e instanceof MessagingError && e.status === 402 ? uiText("There are not enough credits for this language tool.") : e instanceof MessagingError && [401, 403].includes(e.status) ? uiText("This language tool is no longer allowed.") : uiText("This message could not be converted. Try again."));
470
+ setError(uiText(languageFailure(e)));
459
471
  }
460
472
  finally {
461
473
  if (generation === transformGeneration.current)
@@ -508,7 +520,7 @@ const MessagingBubbleView = React.memo(function MessagingBubbleView({ message, p
508
520
  const footer = _jsx(MessageMetadata, { message: message, mine: mine, ink: visual ? '#ffffff' : ink, pendingStatus: deliveryStatus });
509
521
  const bigEmoji = message.kind === 'text' && !message.replyTo && !extra && !canTranslate && !transformed && isBigEmojiText(message.text);
510
522
  const showingTransform = !!transformed && !showOriginal && (transformed.kind === 'transcript' || canTranslate);
511
- const languageActions = (canTranscript || canTranslate || transformed) && _jsxs(View, { testID: "message-language-actions", style: { flexDirection: 'row', flexWrap: 'wrap', justifyContent: voice && !showingTransform ? 'flex-end' : 'flex-start', columnGap: 8, rowGap: 0 }, children: [transformed && _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: showOriginal ? (transformed.kind === 'transcript' ? 'Show transcript' : 'Show translation') : uiText("Show original"), onPress: () => { setTranslationAutoPlay(false); setShowOriginal(v => !v); }, hitSlop: 8, style: { minHeight: 17, paddingVertical: 1, justifyContent: 'center' }, children: _jsx(Text, { style: { color: c.accent, fontSize: 11, lineHeight: 15 }, children: showOriginal ? (transformed.kind === 'transcript' ? 'Show transcript' : 'Show translation') : uiText("Show original") }) }), canTranscript && !transformed && _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText("Read voice message"), disabled: transforming, onPress: () => void transform('transcript'), hitSlop: 8, style: { minHeight: 17, paddingVertical: 1, justifyContent: 'center' }, children: _jsx(Text, { style: { color: c.accent, fontSize: 11, lineHeight: 15 }, children: transforming ? uiText("Transcribing…") : uiText("Transcript") }) }), canTranslate && transformed?.kind !== 'translation' && _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: translation.mode === 'voice' && languageTools?.voiceOutput !== false ? uiText("Play translation") : uiText("Translate message"), disabled: transforming, onPress: () => void transform('translation', translation.mode === 'voice' && languageTools?.voiceOutput !== false ? 'voice' : 'text'), hitSlop: 8, style: { minHeight: 17, paddingVertical: 1, justifyContent: 'center' }, children: _jsx(Text, { style: { color: c.accent, fontSize: 11, lineHeight: 15 }, children: translation.mode === 'voice' && languageTools?.voiceOutput !== false ? uiText("Play Translation") : uiText("Translate") }) })] });
523
+ const languageActions = (canTranscript || canTranslate || transformed) && _jsxs(View, { testID: "message-language-actions", style: { flexDirection: 'row', flexWrap: 'wrap', justifyContent: voice && !showingTransform ? 'flex-end' : 'flex-start', columnGap: 8, rowGap: 0 }, children: [transforming && _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText("Cancel"), onPress: () => { transformAbort.current?.abort(); transformGeneration.current++; setTransforming(false); }, hitSlop: 8, children: _jsx(Text, { style: { color: c.accent, fontSize: 11, lineHeight: 15 }, children: uiText("Cancel") }) }), transformed && _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: showOriginal ? (transformed.kind === 'transcript' ? 'Show transcript' : 'Show translation') : uiText("Show original"), onPress: () => { setTranslationAutoPlay(false); setShowOriginal(v => !v); }, hitSlop: 8, style: { minHeight: 17, paddingVertical: 1, justifyContent: 'center' }, children: _jsx(Text, { style: { color: c.accent, fontSize: 11, lineHeight: 15 }, children: showOriginal ? (transformed.kind === 'transcript' ? 'Show transcript' : 'Show translation') : uiText("Show original") }) }), canTranscript && !transformed && _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText("Read transcript"), disabled: transforming, onPress: () => void transform('transcript'), hitSlop: 8, style: { minHeight: 17, paddingVertical: 1, justifyContent: 'center' }, children: _jsx(Text, { style: { color: c.accent, fontSize: 11, lineHeight: 15 }, children: transforming ? uiText("Transcribing…") : uiText("Transcript") }) }), canTranslate && transformed?.kind !== 'translation' && _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: translation.mode === 'voice' && languageTools?.voiceOutput !== false ? uiText("Play translation") : uiText("Translate message"), disabled: transforming, onPress: () => void transform('translation', translation.mode === 'voice' && languageTools?.voiceOutput !== false ? 'voice' : 'text'), hitSlop: 8, style: { minHeight: 17, paddingVertical: 1, justifyContent: 'center' }, children: _jsx(Text, { style: { color: c.accent, fontSize: 11, lineHeight: 15 }, children: translation.mode === 'voice' && languageTools?.voiceOutput !== false ? uiText("Play Translation") : uiText("Translate") }) })] });
512
524
  const fallbackContent = _jsx(View, { testID: "message-original-text", children: _jsx(Text, { selectable: true, style: { color: ink, fontSize: 16, lineHeight: 22 }, children: renderText(message.text ?? '') }) });
513
525
  const originalContent = message.custom && !message.deleted ? _jsxs(Pressable, { onLongPress: menu, children: [_jsx(CustomMessage, { message: message, mine: mine, appearance: design, pendingStatus: pendingStatus, components: components, enabled: canInteract, children: fallbackContent }), pendingStatus && footer] }) : extra?.weather || extra?.call ? extraCard : message.kind === 'poll' ? _jsx(PollMessage, { onLongPress: menu, message: message, userId: userId, ink: ink, accent: c.accent, background: c.background, foreground: c.foreground, resolveVoterName: id => id === userId ? 'You' : participants?.[id]?.name ?? (state.conversation?.kind === 'direct' ? contextContactName : 'Chat member'), enabled: canInteract && !!state.settings?.features.poll, onVote: options => client.vote(message.id, options), onClose: () => client.closePoll(message.id) }) : message.kind === 'text' ? _jsxs(View, { testID: "message-original-text", children: [_jsx(Text, { selectable: true, style: { color: ink, fontSize: bigEmoji ? 48 : 16, lineHeight: bigEmoji ? 58 : 22 }, children: renderText(message.text ?? '') }), pendingStatus && footer] }) : _jsx(MediaContent, { message: message, ink: ink, accent: c.accent, footer: voice ? languageActions : undefined, onOpen: () => void open(), onLongPress: menu });
514
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@robono/messaging-react-native",
3
- "version": "0.18.0",
3
+ "version": "0.20.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.13.0",
60
+ "@robono/messaging": "^0.15.0",
61
61
  "react": ">=18.2 <20",
62
62
  "react-native": ">=0.76 <1",
63
63
  "expo-audio": ">=55 <57",