@webority/mobile-chat 0.140.5 → 0.141.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 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.WEB_STRONG=void 0,exports.defaultOpenTarget=defaultOpenTarget,exports.focusForAccessibility=focusForAccessibility,exports.messageSignature=messageSignature,exports.openExternalUrl=openExternalUrl;var _mobileCore=require("@webority/mobile-core"),_reactNative=require("react-native");function focusForAccessibility(e){if(null==e)return;if("web"===_reactNative.Platform.OS)return void e.focus?.();const t=(0,_reactNative.findNodeHandle)(e);null!==t&&_reactNative.AccessibilityInfo.setAccessibilityFocus(t)}function messageSignature(e){let t=0;for(const r of e.parts)"Text"===r.kind&&(t+=r.text.length);return`${e.id}|${e.parts.length}|${t}`}const ABSOLUTE_WEB_URL=/^https?:\/\//i;function openExternalUrl(e){_reactNative.Linking.openURL(e).catch(e=>{throw _mobileCore.Logger.error("[chat] link did not open",e),e})}function defaultOpenTarget(e){ABSOLUTE_WEB_URL.test(e)&&openExternalUrl(e)}const WEB_STRONG=exports.WEB_STRONG="web"===_reactNative.Platform.OS?{role:"strong"}:{};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.WEB_STRONG=void 0,exports.defaultOpenTarget=defaultOpenTarget,exports.focusForAccessibility=focusForAccessibility,exports.messageSignature=messageSignature,exports.openExternalUrl=openExternalUrl;var _mobileCore=require("@webority/mobile-core"),_reactNative=require("react-native");function focusForAccessibility(e){if(null==e)return;if("web"===_reactNative.Platform.OS)return void e.focus?.();const t=(0,_reactNative.findNodeHandle)(e);null!=t&&_reactNative.AccessibilityInfo.setAccessibilityFocus(t)}function messageSignature(e){let t=0;for(const r of e.parts)"Text"===r.kind&&(t+=r.text.length);return`${e.id}|${e.parts.length}|${t}`}const ABSOLUTE_WEB_URL=/^https?:\/\//i;function openExternalUrl(e){_reactNative.Linking.openURL(e).catch(e=>{throw _mobileCore.Logger.error("[chat] link did not open",e),e})}function defaultOpenTarget(e){ABSOLUTE_WEB_URL.test(e)&&openExternalUrl(e)}const WEB_STRONG=exports.WEB_STRONG="web"===_reactNative.Platform.OS?{role:"strong"}:{};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SpeechRequestError=void 0,exports.synthesizeSpeech=synthesizeSpeech,exports.transcribeClip=transcribeClip;var _chatCore=require("@webority/chat-core"),_mobileCore=require("@webority/mobile-core"),_speechText=require("./speechText.js");const TRANSCRIBE_API_VERSION="2024-11-15",TTS_OUTPUT_FORMAT="audio-24khz-48kbitrate-mono-mp3",REQUEST_TIMEOUT_MS=15e3,REGION_PATTERN=/^[a-z0-9]+$/;class SpeechRequestError extends Error{constructor(e){super(`Speech request failed with status ${e}`),this.name="SpeechRequestError",this.status=e}}exports.SpeechRequestError=SpeechRequestError;const assertRegion=e=>{if(!REGION_PATTERN.test(e))throw new _chatCore.ChatSpeechError("Unavailable","Speech is not available.")},withTimeout=async(e,t)=>{const r=new AbortController,abort=()=>r.abort(),o=setTimeout(abort,15e3);e?.aborted&&r.abort(),e?.addEventListener("abort",abort);try{return await t(r.signal)}finally{clearTimeout(o),e?.removeEventListener("abort",abort)}};async function transcribeClip(e){const{token:t,uri:r,language:o,signal:i,fetchImpl:s=fetch}=e;assertRegion(t.region);const a=new FormData;return a.append("audio",{uri:r,name:"dictation.m4a",type:"audio/mp4"}),a.append("definition",JSON.stringify({locales:[o]})),withTimeout(i,async e=>{const r=await(0,_mobileCore.fetchWithRetry)(s,`https://${t.region}.api.cognitive.microsoft.com/speechtotext/transcriptions:transcribe?api-version=${TRANSCRIBE_API_VERSION}`,{method:"POST",headers:{Authorization:`Bearer ${t.token}`},body:a,signal:e});if(!r.ok)throw new SpeechRequestError(r.status);const o=await r.json();if(!Array.isArray(o.combinedPhrases))throw new _chatCore.ChatSpeechError("Unavailable","Speech is not available.");return o.combinedPhrases.map(e=>e.text??"").join(" ").trim()})}async function synthesizeSpeech(e){const{token:t,text:r,language:o,voice:i,signal:s,fetchImpl:a=fetch}=e;return assertRegion(t.region),withTimeout(s,async e=>{const s=await(0,_mobileCore.fetchWithRetry)(a,`https://${t.region}.tts.speech.microsoft.com/cognitiveservices/v1`,{method:"POST",headers:{Authorization:`Bearer ${t.token}`,"Content-Type":"application/ssml+xml","X-Microsoft-OutputFormat":TTS_OUTPUT_FORMAT,"User-Agent":"webority-chat"},body:(0,_speechText.buildSsml)((0,_speechText.clampSpeakText)(r),o,i),signal:e});if(!s.ok)throw new SpeechRequestError(s.status);return new Uint8Array(await s.arrayBuffer())})}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SpeechRequestError=void 0,exports.synthesizeSpeech=synthesizeSpeech,exports.transcribeClip=transcribeClip;var _chatCore=require("@webority/chat-core"),_mobileCore=require("@webority/mobile-core"),_speechText=require("./speechText.js");const TRANSCRIBE_API_VERSION="2024-11-15",TTS_OUTPUT_FORMAT="audio-24khz-48kbitrate-mono-mp3",REQUEST_TIMEOUT_MS=15e3,REGION_PATTERN=/^[a-z0-9]+$/,SPEECH_RETRY={sideEffectFree:!0};class SpeechRequestError extends Error{constructor(e){super(`Speech request failed with status ${e}`),this.name="SpeechRequestError",this.status=e}}exports.SpeechRequestError=SpeechRequestError;const assertRegion=e=>{if(!REGION_PATTERN.test(e))throw new _chatCore.ChatSpeechError("Unavailable","Speech is not available.")},withTimeout=async(e,t)=>{const r=new AbortController,abort=()=>r.abort(),o=setTimeout(abort,15e3);e?.aborted&&r.abort(),e?.addEventListener("abort",abort);try{return await t(r.signal)}finally{clearTimeout(o),e?.removeEventListener("abort",abort)}};async function transcribeClip(e){const{token:t,uri:r,language:o,signal:i,fetchImpl:s=fetch}=e;assertRegion(t.region);const a=new FormData;return a.append("audio",{uri:r,name:"dictation.m4a",type:"audio/mp4"}),a.append("definition",JSON.stringify({locales:[o]})),withTimeout(i,async e=>{const r=await(0,_mobileCore.fetchWithRetry)(s,`https://${t.region}.api.cognitive.microsoft.com/speechtotext/transcriptions:transcribe?api-version=${TRANSCRIBE_API_VERSION}`,{method:"POST",headers:{Authorization:`Bearer ${t.token}`},body:a,signal:e},SPEECH_RETRY);if(!r.ok)throw new SpeechRequestError(r.status);const o=await r.json();if(!Array.isArray(o.combinedPhrases))throw new _chatCore.ChatSpeechError("Unavailable","Speech is not available.");return o.combinedPhrases.map(e=>e.text??"").join(" ").trim()})}async function synthesizeSpeech(e){const{token:t,text:r,language:o,voice:i,signal:s,fetchImpl:a=fetch}=e;return assertRegion(t.region),withTimeout(s,async e=>{const s=await(0,_mobileCore.fetchWithRetry)(a,`https://${t.region}.tts.speech.microsoft.com/cognitiveservices/v1`,{method:"POST",headers:{Authorization:`Bearer ${t.token}`,"Content-Type":"application/ssml+xml","X-Microsoft-OutputFormat":TTS_OUTPUT_FORMAT,"User-Agent":"webority-chat"},body:(0,_speechText.buildSsml)((0,_speechText.clampSpeakText)(r),o,i),signal:e},SPEECH_RETRY);if(!s.ok)throw new SpeechRequestError(s.status);return new Uint8Array(await s.arrayBuffer())})}
@@ -1 +1 @@
1
- "use strict";import{Logger}from"@webority/mobile-core";import{AccessibilityInfo,findNodeHandle,Linking,Platform}from"react-native";export function focusForAccessibility(t){if(null==t)return;if("web"===Platform.OS)return void t.focus?.();const e=findNodeHandle(t);null!==e&&AccessibilityInfo.setAccessibilityFocus(e)}export function messageSignature(t){let e=0;for(const o of t.parts)"Text"===o.kind&&(e+=o.text.length);return`${t.id}|${t.parts.length}|${e}`}const ABSOLUTE_WEB_URL=/^https?:\/\//i;export function openExternalUrl(t){Linking.openURL(t).catch(t=>{throw Logger.error("[chat] link did not open",t),t})}export function defaultOpenTarget(t){ABSOLUTE_WEB_URL.test(t)&&openExternalUrl(t)}export const WEB_STRONG="web"===Platform.OS?{role:"strong"}:{};
1
+ "use strict";import{Logger}from"@webority/mobile-core";import{AccessibilityInfo,findNodeHandle,Linking,Platform}from"react-native";export function focusForAccessibility(t){if(null==t)return;if("web"===Platform.OS)return void t.focus?.();const e=findNodeHandle(t);null!=e&&AccessibilityInfo.setAccessibilityFocus(e)}export function messageSignature(t){let e=0;for(const o of t.parts)"Text"===o.kind&&(e+=o.text.length);return`${t.id}|${t.parts.length}|${e}`}const ABSOLUTE_WEB_URL=/^https?:\/\//i;export function openExternalUrl(t){Linking.openURL(t).catch(t=>{throw Logger.error("[chat] link did not open",t),t})}export function defaultOpenTarget(t){ABSOLUTE_WEB_URL.test(t)&&openExternalUrl(t)}export const WEB_STRONG="web"===Platform.OS?{role:"strong"}:{};
@@ -1 +1 @@
1
- "use strict";import{ChatSpeechError}from"@webority/chat-core";import{fetchWithRetry}from"@webority/mobile-core";import{buildSsml,clampSpeakText}from"./speechText.js";const TRANSCRIBE_API_VERSION="2024-11-15",TTS_OUTPUT_FORMAT="audio-24khz-48kbitrate-mono-mp3",REQUEST_TIMEOUT_MS=15e3,REGION_PATTERN=/^[a-z0-9]+$/;export class SpeechRequestError extends Error{constructor(e){super(`Speech request failed with status ${e}`),this.name="SpeechRequestError",this.status=e}}const assertRegion=e=>{if(!REGION_PATTERN.test(e))throw new ChatSpeechError("Unavailable","Speech is not available.")},withTimeout=async(e,t)=>{const r=new AbortController,abort=()=>r.abort(),o=setTimeout(abort,15e3);e?.aborted&&r.abort(),e?.addEventListener("abort",abort);try{return await t(r.signal)}finally{clearTimeout(o),e?.removeEventListener("abort",abort)}};export async function transcribeClip(e){const{token:t,uri:r,language:o,signal:i,fetchImpl:a=fetch}=e;assertRegion(t.region);const n=new FormData;return n.append("audio",{uri:r,name:"dictation.m4a",type:"audio/mp4"}),n.append("definition",JSON.stringify({locales:[o]})),withTimeout(i,async e=>{const r=await fetchWithRetry(a,`https://${t.region}.api.cognitive.microsoft.com/speechtotext/transcriptions:transcribe?api-version=2024-11-15`,{method:"POST",headers:{Authorization:`Bearer ${t.token}`},body:n,signal:e});if(!r.ok)throw new SpeechRequestError(r.status);const o=await r.json();if(!Array.isArray(o.combinedPhrases))throw new ChatSpeechError("Unavailable","Speech is not available.");return o.combinedPhrases.map(e=>e.text??"").join(" ").trim()})}export async function synthesizeSpeech(e){const{token:t,text:r,language:o,voice:i,signal:a,fetchImpl:n=fetch}=e;return assertRegion(t.region),withTimeout(a,async e=>{const a=await fetchWithRetry(n,`https://${t.region}.tts.speech.microsoft.com/cognitiveservices/v1`,{method:"POST",headers:{Authorization:`Bearer ${t.token}`,"Content-Type":"application/ssml+xml","X-Microsoft-OutputFormat":TTS_OUTPUT_FORMAT,"User-Agent":"webority-chat"},body:buildSsml(clampSpeakText(r),o,i),signal:e});if(!a.ok)throw new SpeechRequestError(a.status);return new Uint8Array(await a.arrayBuffer())})}
1
+ "use strict";import{ChatSpeechError}from"@webority/chat-core";import{fetchWithRetry}from"@webority/mobile-core";import{buildSsml,clampSpeakText}from"./speechText.js";const TRANSCRIBE_API_VERSION="2024-11-15",TTS_OUTPUT_FORMAT="audio-24khz-48kbitrate-mono-mp3",REQUEST_TIMEOUT_MS=15e3,REGION_PATTERN=/^[a-z0-9]+$/,SPEECH_RETRY={sideEffectFree:!0};export class SpeechRequestError extends Error{constructor(e){super(`Speech request failed with status ${e}`),this.name="SpeechRequestError",this.status=e}}const assertRegion=e=>{if(!REGION_PATTERN.test(e))throw new ChatSpeechError("Unavailable","Speech is not available.")},withTimeout=async(e,t)=>{const r=new AbortController,abort=()=>r.abort(),o=setTimeout(abort,15e3);e?.aborted&&r.abort(),e?.addEventListener("abort",abort);try{return await t(r.signal)}finally{clearTimeout(o),e?.removeEventListener("abort",abort)}};export async function transcribeClip(e){const{token:t,uri:r,language:o,signal:i,fetchImpl:a=fetch}=e;assertRegion(t.region);const n=new FormData;return n.append("audio",{uri:r,name:"dictation.m4a",type:"audio/mp4"}),n.append("definition",JSON.stringify({locales:[o]})),withTimeout(i,async e=>{const r=await fetchWithRetry(a,`https://${t.region}.api.cognitive.microsoft.com/speechtotext/transcriptions:transcribe?api-version=2024-11-15`,{method:"POST",headers:{Authorization:`Bearer ${t.token}`},body:n,signal:e},SPEECH_RETRY);if(!r.ok)throw new SpeechRequestError(r.status);const o=await r.json();if(!Array.isArray(o.combinedPhrases))throw new ChatSpeechError("Unavailable","Speech is not available.");return o.combinedPhrases.map(e=>e.text??"").join(" ").trim()})}export async function synthesizeSpeech(e){const{token:t,text:r,language:o,voice:i,signal:a,fetchImpl:n=fetch}=e;return assertRegion(t.region),withTimeout(a,async e=>{const a=await fetchWithRetry(n,`https://${t.region}.tts.speech.microsoft.com/cognitiveservices/v1`,{method:"POST",headers:{Authorization:`Bearer ${t.token}`,"Content-Type":"application/ssml+xml","X-Microsoft-OutputFormat":TTS_OUTPUT_FORMAT,"User-Agent":"webority-chat"},body:buildSsml(clampSpeakText(r),o,i),signal:e},SPEECH_RETRY);if(!a.ok)throw new SpeechRequestError(a.status);return new Uint8Array(await a.arrayBuffer())})}
@@ -1,6 +1,6 @@
1
1
  import type { ChatLauncherMark, ChatLook } from "@webority/chat-core";
2
2
  import type React from "react";
3
- import { type View } from "react-native";
3
+ import { type HostInstance } from "react-native";
4
4
  export interface ChatLauncherProps {
5
5
  look: ChatLook;
6
6
  /** The chat is open. The launcher leaves: at once, or by shrinking first when the look is expressive. */
@@ -14,7 +14,7 @@ export interface ChatLauncherProps {
14
14
  reduced: boolean;
15
15
  mark?: ChatLauncherMark;
16
16
  avatar?: string | null;
17
- buttonRef: React.RefObject<View | null>;
17
+ buttonRef: React.RefObject<HostInstance | null>;
18
18
  onPress: () => void;
19
19
  testID: string;
20
20
  }
@@ -1,6 +1,6 @@
1
1
  import type { ChatLiveMessage, ChatPart, ChatPartKind, ChatTurnApi, ChatUploadFile } from "@webority/chat-core";
2
2
  import type React from "react";
3
- import type { View } from "react-native";
3
+ import type { HostInstance } from "react-native";
4
4
  export type { ChatLookInput, ChatMotion } from "@webority/chat-core";
5
5
  /**
6
6
  * The web chat's appearance keys that the phone reads, under the names applyAppearance and the
@@ -23,7 +23,7 @@ export interface ChatAppearance {
23
23
  /** Host values the thread adds to each part's turn: the host's link resolver and the source rows a citation focuses. */
24
24
  export interface ChatTurnHostApi {
25
25
  resolveLink?: (href: string) => string | null;
26
- registerSourceRow?: (marker: string, row: View | null) => void;
26
+ registerSourceRow?: (marker: string, row: HostInstance | null) => void;
27
27
  /** Moves focus to the composer input after a quick reply is chosen. */
28
28
  focusComposer?: () => void;
29
29
  }
@@ -1,6 +1,6 @@
1
1
  import type { ChatLauncherMark, ChatLook } from "@webority/chat-core";
2
2
  import type React from "react";
3
- import { type View } from "react-native";
3
+ import { type HostInstance } from "react-native";
4
4
  export interface ChatLauncherProps {
5
5
  look: ChatLook;
6
6
  /** The chat is open. The launcher leaves: at once, or by shrinking first when the look is expressive. */
@@ -14,7 +14,7 @@ export interface ChatLauncherProps {
14
14
  reduced: boolean;
15
15
  mark?: ChatLauncherMark;
16
16
  avatar?: string | null;
17
- buttonRef: React.RefObject<View | null>;
17
+ buttonRef: React.RefObject<HostInstance | null>;
18
18
  onPress: () => void;
19
19
  testID: string;
20
20
  }
@@ -1,6 +1,6 @@
1
1
  import type { ChatLiveMessage, ChatPart, ChatPartKind, ChatTurnApi, ChatUploadFile } from "@webority/chat-core";
2
2
  import type React from "react";
3
- import type { View } from "react-native";
3
+ import type { HostInstance } from "react-native";
4
4
  export type { ChatLookInput, ChatMotion } from "@webority/chat-core";
5
5
  /**
6
6
  * The web chat's appearance keys that the phone reads, under the names applyAppearance and the
@@ -23,7 +23,7 @@ export interface ChatAppearance {
23
23
  /** Host values the thread adds to each part's turn: the host's link resolver and the source rows a citation focuses. */
24
24
  export interface ChatTurnHostApi {
25
25
  resolveLink?: (href: string) => string | null;
26
- registerSourceRow?: (marker: string, row: View | null) => void;
26
+ registerSourceRow?: (marker: string, row: HostInstance | null) => void;
27
27
  /** Moves focus to the composer input after a quick reply is chosen. */
28
28
  focusComposer?: () => void;
29
29
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webority/mobile-chat",
3
- "version": "0.140.5",
3
+ "version": "0.141.0",
4
4
  "description": "Webority Chat for React Native apps: the chat screen, sheet and embedded shells, thread, composer, one renderer per message part kind and the useChat hook, built on @webority/chat-core and @webority/mobile-ui.",
5
5
  "keywords": [
6
6
  "react-native",
@@ -42,14 +42,14 @@
42
42
  "!**/*.map"
43
43
  ],
44
44
  "peerDependencies": {
45
- "@webority/chat-core": "0.140.5",
46
- "@webority/markdown-core": "^0.146.0",
47
- "@webority/mobile-core": "^0.146.0",
48
- "@webority/mobile-ui": "^0.146.0",
49
- "expo-audio": ">=57.0.0",
50
- "expo-file-system": ">=57.0.0",
51
- "react": "^19.1.0",
52
- "react-native": ">=0.81.0",
45
+ "@webority/chat-core": "0.141.0",
46
+ "@webority/markdown-core": "^0.149.0",
47
+ "@webority/mobile-core": "^0.149.0",
48
+ "@webority/mobile-ui": "^0.149.0",
49
+ "expo-audio": ">=58.0.0",
50
+ "expo-file-system": ">=58.0.0",
51
+ "react": "^19.3.0",
52
+ "react-native": ">=0.88.0",
53
53
  "react-native-keyboard-controller": ">=1.21.9",
54
54
  "react-native-safe-area-context": ">=5.4.0"
55
55
  },
@@ -92,41 +92,41 @@
92
92
  ]
93
93
  },
94
94
  "devDependencies": {
95
- "@react-native/babel-preset": "0.86.3",
96
- "@react-native/jest-preset": "0.86.3",
97
- "@react-native/metro-config": "0.86.3",
95
+ "@react-native/babel-preset": "0.88.1",
96
+ "@react-native/jest-preset": "0.88.1",
97
+ "@react-native/metro-config": "0.88.1",
98
98
  "@testing-library/react-native": "12.9.0",
99
99
  "@types/jest": "29.5.14",
100
- "@types/react": "19.2.18",
101
- "@webority/canvas-kit": "0.146.2",
102
- "@webority/chat-core": "0.140.5",
103
- "@webority/markdown-core": "0.146.2",
104
- "@webority/mobile-core": "0.146.2",
105
- "@webority/mobile-ui": "0.146.2",
100
+ "@types/react": "19.3.0",
101
+ "@webority/canvas-kit": "0.149.0",
102
+ "@webority/chat-core": "0.141.0",
103
+ "@webority/markdown-core": "0.149.0",
104
+ "@webority/mobile-core": "0.149.0",
105
+ "@webority/mobile-ui": "0.149.0",
106
106
  "babel-jest": "29.7.0",
107
- "expo": "57.0.31",
108
- "expo-application": "57.0.3",
109
- "expo-audio": "57.0.5",
110
- "expo-clipboard": "57.0.2",
111
- "expo-crypto": "57.0.4",
112
- "expo-file-system": "57.0.7",
113
- "expo-haptics": "57.0.3",
114
- "expo-image": "57.0.5",
115
- "expo-network": "57.0.3",
116
- "expo-secure-store": "57.0.4",
117
- "expo-sqlite": "57.0.4",
107
+ "expo": "58.0.23",
108
+ "expo-application": "58.1.2",
109
+ "expo-audio": "58.0.11",
110
+ "expo-clipboard": "58.0.4",
111
+ "expo-crypto": "58.0.7",
112
+ "expo-file-system": "58.0.13",
113
+ "expo-haptics": "58.0.7",
114
+ "expo-image": "58.0.18",
115
+ "expo-network": "58.0.4",
116
+ "expo-secure-store": "58.0.2",
117
+ "expo-sqlite": "58.0.15",
118
118
  "jest": "29.7.0",
119
- "react": "19.2.8",
119
+ "react": "19.3.0",
120
120
  "react-hook-form": "7.89.0",
121
- "react-native": "0.86.3",
121
+ "react-native": "0.88.1",
122
122
  "react-native-builder-bob": "0.43.0",
123
- "react-native-gesture-handler": "3.2.1",
124
- "react-native-keyboard-controller": "1.21.9",
125
- "react-native-reanimated": "4.5.3",
126
- "react-native-safe-area-context": "5.9.1",
127
- "react-native-svg": "15.15.5",
128
- "react-native-worklets": "0.10.4",
129
- "react-test-renderer": "19.2.8",
123
+ "react-native-gesture-handler": "3.3.0",
124
+ "react-native-keyboard-controller": "1.22.7",
125
+ "react-native-reanimated": "4.7.1",
126
+ "react-native-safe-area-context": "5.11.1",
127
+ "react-native-svg": "15.16.0",
128
+ "react-native-worklets": "0.13.0",
129
+ "react-test-renderer": "19.3.0",
130
130
  "terser": "5.49.1",
131
131
  "typescript": "5.9.3"
132
132
  },