@webority/mobile-chat 0.139.0 → 0.140.1
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/lib/commonjs/ChatFooter.js +1 -1
- package/lib/commonjs/chatShared.js +1 -1
- package/lib/commonjs/renderers/ActionPart.js +1 -1
- package/lib/commonjs/speech/azureSpeech.js +1 -1
- package/lib/module/ChatFooter.js +1 -1
- package/lib/module/chatShared.js +1 -1
- package/lib/module/renderers/ActionPart.js +1 -1
- package/lib/module/speech/azureSpeech.js +1 -1
- package/lib/typescript/commonjs/chatShared.d.ts +1 -0
- package/lib/typescript/module/chatShared.d.ts +1 -0
- package/package.json +10 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChatFooter=ChatFooter;var _chatCore=require("@webority/chat-core"),_mobileUi=require("@webority/mobile-ui"),_reactNative=require("react-native"),_jsxRuntime=require("react/jsx-runtime");const GOOGLE_PRIVACY="https://policies.google.com/privacy",GOOGLE_TERMS="https://policies.google.com/terms",openLink=e=>
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChatFooter=ChatFooter;var _chatCore=require("@webority/chat-core"),_mobileUi=require("@webority/mobile-ui"),_reactNative=require("react-native"),_chatShared=require("./chatShared.js"),_jsxRuntime=require("react/jsx-runtime");const GOOGLE_PRIVACY="https://policies.google.com/privacy",GOOGLE_TERMS="https://policies.google.com/terms",openLink=e=>(0,_chatShared.openExternalUrl)(e);function ChatFooter({chat:e,labels:i}){const t=(0,_mobileUi.useTheme)(),r=e.profile;if(!r)return null;const o=r.footer.disclaimer||i.disclaimer,n=r.footer.privacyUrl,a=r.footer.assuranceText,l=r.footer.privacyText,c=(0,_chatCore.showsCaptchaNote)(r);return Boolean(o)||Boolean(l)||Boolean(n)||Boolean(a)||c?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:t.space.xxs,alignItems:"center"},children:[o?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"tertiary",align:"center",children:o}):null,l?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"tertiary",align:"center",children:l}):null,n?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"link",accessibilityRole:"link",onPress:()=>openLink(n),children:i.footerPrivacy}):null,a?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"tertiary",align:"center",children:a}):null,c?(0,_jsxRuntime.jsxs)(_mobileUi.Text,{variant:"caption",color:"tertiary",align:"center",children:[i.captchaNote," ",(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"link",accessibilityRole:"link",onPress:()=>openLink(GOOGLE_PRIVACY),children:i.captchaPrivacy})," ",(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"link",accessibilityRole:"link",onPress:()=>openLink(GOOGLE_TERMS),children:i.captchaTerms})]}):null]}):null}
|
|
@@ -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;var _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
|
|
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.ActionPart=ActionPart;var _chatCore=require("@webority/chat-core"),_markdownCore=require("@webority/markdown-core"),_mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_NoticePart=require("./NoticePart.js"),_jsxRuntime=require("react/jsx-runtime");const LEAD_CAPTURE="ChatLeadCapture",SAFE_LINK=/^https?:\/\//i,inlineNodes=(e,t)=>e.map(e=>{if("text"===e.type||"code"===e.type||"citation"===e.type)return e.text;if("link"===e.type){const i=inlineNodes(e.children,t);return SAFE_LINK.test(e.href)?(0,_jsxRuntime.jsx)(_reactNative.Text,{accessibilityRole:"link",style:{color:t.colors.link,textDecorationLine:"underline"},onPress:()=>
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ActionPart=ActionPart;var _chatCore=require("@webority/chat-core"),_markdownCore=require("@webority/markdown-core"),_mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_chatShared=require("../chatShared.js"),_NoticePart=require("./NoticePart.js"),_jsxRuntime=require("react/jsx-runtime");const LEAD_CAPTURE="ChatLeadCapture",SAFE_LINK=/^https?:\/\//i,inlineNodes=(e,t)=>e.map(e=>{if("text"===e.type||"code"===e.type||"citation"===e.type)return e.text;if("link"===e.type){const i=inlineNodes(e.children,t);return SAFE_LINK.test(e.href)?(0,_jsxRuntime.jsx)(_reactNative.Text,{accessibilityRole:"link",style:{color:t.colors.link,textDecorationLine:"underline"},onPress:()=>(0,_chatShared.openExternalUrl)(e.href),children:i},e.key):(0,_jsxRuntime.jsx)(_reactNative.Text,{children:i},e.key)}if("image"===e.type)return null;const i="strong"===e.type?{fontWeight:t.weight.bold}:"em"===e.type?{fontStyle:"italic"}:{textDecorationLine:"line-through"};return(0,_jsxRuntime.jsx)(_reactNative.Text,{style:i,children:inlineNodes(e.children,t)},e.key)}),splitLine=e=>{const t=e.indexOf(": ");return t<0?{term:e,detail:null}:{term:e.slice(0,t),detail:e.slice(t+2)}},statusLine=(e,t)=>{switch(e.state){case"Confirmed":return t.actionConfirmed;case"Done":return e.decidedDateTimeUtc?`${t.actionDone} ${(0,_chatCore.formatChatDate)(e.decidedDateTimeUtc)}`:t.actionDone;case"Rejected":return t.actionRejected;case"Expired":return t.actionExpired;case"Failed":return t.actionFailed;case"Repeat":return e.decidedDateTimeUtc?t.actionRepeat((0,_chatCore.formatChatDate)(e.decidedDateTimeUtc)):t.actionDone;case"Pending":return""}};function ActionBody({part:e,turn:t}){const i=(0,_mobileUi.useTheme)(),{labels:n,features:a}=t,[r,o]=(0,_react.useState)(null),[s,l]=(0,_react.useState)(""),[c,d]=(0,_react.useState)(!1),run=async(e,t)=>{o(e),l("");try{await t()}catch(e){const t=e?.message;l("string"==typeof t&&""!==t?t:n.actionFailed),o(null)}},u=(e.editFields??[]).map(e=>({label:e.label,value:e.id})),m=a.LeadRecap&&e.actionKind===LEAD_CAPTURE,x=m&&u.length>0,_=m&&e.confirmLabel||n.actionConfirm,j=m&&e.rejectLabel||n.actionDismiss,p=null!==r;return(0,_jsxRuntime.jsxs)(_mobileUi.Card,{variant:"outline",padding:"sm",children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{gap:i.space.sm},children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"label",children:e.title}),e.lines.map(e=>{if(!m)return(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",children:e},e);const{term:t,detail:n}=splitLine(e);return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flexDirection:"row",flexWrap:"wrap",gap:i.space.xs},children:[(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"label",children:t}),null!==n?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",children:n}):null]},e)}),m&&e.consentText?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:inlineNodes((0,_markdownCore.parseInline)(e.consentText),i)}):null,"Pending"===e.state?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[""!==s?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"danger",accessibilityLiveRegion:"polite",children:s}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flexDirection:"row",flexWrap:"wrap",gap:i.space.sm},children:[(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:"confirm"===r?n.actionWorking:_,loading:"confirm"===r,disabled:p,onPress:()=>{run("confirm",()=>t.confirmAction(e.actionId))}}),(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:j,variant:"ghost",disabled:p,onPress:()=>{run("reject",()=>t.rejectAction(e.actionId))}})]})]}):(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"bodySmall",color:"Done"===e.state||"Confirmed"===e.state||"Repeat"===e.state?"success":"secondary",children:statusLine(e,n)}),x?(0,_jsxRuntime.jsx)(_mobileUi.Button,{label:n.editSomething,variant:"ghost",disabled:p||"Pending"!==e.state,onPress:()=>d(!0)}):null,e.note?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"secondary",children:e.note}):null]}),x?(0,_jsxRuntime.jsx)(_mobileUi.OptionSheet,{open:c,onClose:()=>d(!1),title:n.editSomething,options:u,onChange:(e,i)=>{d(!1),t.chooseQuickReply({id:`lead.edit:${String(i.value)}`,label:i.label,action:"Send",target:null,navigateAfterMs:null,icon:null,variant:null})}}):null]})}function ActionPart(e){const{part:t,message:i,turn:n}=e;if("Action"!==t.kind){const e={kind:"Notice",code:"NeedsNewerApp",text:n.labels.needsNewerApp};return(0,_jsxRuntime.jsx)(_NoticePart.NoticePart,{part:e,message:i,turn:n})}return(0,_jsxRuntime.jsx)(ActionBody,{part:t,turn:n},t.actionId)}
|
|
@@ -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);
|
|
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())})}
|
package/lib/module/ChatFooter.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{showsCaptchaNote}from"@webority/chat-core";import{Text,useTheme}from"@webority/mobile-ui";import{
|
|
1
|
+
"use strict";import{showsCaptchaNote}from"@webority/chat-core";import{Text,useTheme}from"@webority/mobile-ui";import{View}from"react-native";import{openExternalUrl}from"./chatShared.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const GOOGLE_PRIVACY="https://policies.google.com/privacy",GOOGLE_TERMS="https://policies.google.com/terms",openLink=e=>openExternalUrl(e);export function ChatFooter({chat:e,labels:t}){const o=useTheme(),r=e.profile;if(!r)return null;const i=r.footer.disclaimer||t.disclaimer,n=r.footer.privacyUrl,a=r.footer.assuranceText,l=r.footer.privacyText,c=showsCaptchaNote(r);return Boolean(i)||Boolean(l)||Boolean(n)||Boolean(a)||c?_jsxs(View,{style:{gap:o.space.xxs,alignItems:"center"},children:[i?_jsx(Text,{variant:"caption",color:"tertiary",align:"center",children:i}):null,l?_jsx(Text,{variant:"caption",color:"tertiary",align:"center",children:l}):null,n?_jsx(Text,{variant:"caption",color:"link",accessibilityRole:"link",onPress:()=>openLink(n),children:t.footerPrivacy}):null,a?_jsx(Text,{variant:"caption",color:"tertiary",align:"center",children:a}):null,c?_jsxs(Text,{variant:"caption",color:"tertiary",align:"center",children:[t.captchaNote," ",_jsx(Text,{variant:"caption",color:"link",accessibilityRole:"link",onPress:()=>openLink(GOOGLE_PRIVACY),children:t.captchaPrivacy})," ",_jsx(Text,{variant:"caption",color:"link",accessibilityRole:"link",onPress:()=>openLink(GOOGLE_TERMS),children:t.captchaTerms})]}):null]}):null}
|
package/lib/module/chatShared.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";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
|
|
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{formatChatDate}from"@webority/chat-core";import{parseInline}from"@webority/markdown-core";import{Button,Card,OptionSheet,Text,useTheme}from"@webority/mobile-ui";import{useState}from"react";import{
|
|
1
|
+
"use strict";import{formatChatDate}from"@webority/chat-core";import{parseInline}from"@webority/markdown-core";import{Button,Card,OptionSheet,Text,useTheme}from"@webority/mobile-ui";import{useState}from"react";import{Text as RNText,View}from"react-native";import{openExternalUrl}from"../chatShared.js";import{NoticePart}from"./NoticePart.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const LEAD_CAPTURE="ChatLeadCapture",SAFE_LINK=/^https?:\/\//i,inlineNodes=(e,t)=>e.map(e=>{if("text"===e.type||"code"===e.type||"citation"===e.type)return e.text;if("link"===e.type){const n=inlineNodes(e.children,t);return SAFE_LINK.test(e.href)?_jsx(RNText,{accessibilityRole:"link",style:{color:t.colors.link,textDecorationLine:"underline"},onPress:()=>openExternalUrl(e.href),children:n},e.key):_jsx(RNText,{children:n},e.key)}if("image"===e.type)return null;const n="strong"===e.type?{fontWeight:t.weight.bold}:"em"===e.type?{fontStyle:"italic"}:{textDecorationLine:"line-through"};return _jsx(RNText,{style:n,children:inlineNodes(e.children,t)},e.key)}),splitLine=e=>{const t=e.indexOf(": ");return t<0?{term:e,detail:null}:{term:e.slice(0,t),detail:e.slice(t+2)}},statusLine=(e,t)=>{switch(e.state){case"Confirmed":return t.actionConfirmed;case"Done":return e.decidedDateTimeUtc?`${t.actionDone} ${formatChatDate(e.decidedDateTimeUtc)}`:t.actionDone;case"Rejected":return t.actionRejected;case"Expired":return t.actionExpired;case"Failed":return t.actionFailed;case"Repeat":return e.decidedDateTimeUtc?t.actionRepeat(formatChatDate(e.decidedDateTimeUtc)):t.actionDone;case"Pending":return""}};function ActionBody({part:e,turn:t}){const n=useTheme(),{labels:i,features:a}=t,[r,o]=useState(null),[s,l]=useState(""),[c,d]=useState(!1),run=async(e,t)=>{o(e),l("");try{await t()}catch(e){const t=e?.message;l("string"==typeof t&&""!==t?t:i.actionFailed),o(null)}},u=(e.editFields??[]).map(e=>({label:e.label,value:e.id})),m=a.LeadRecap&&e.actionKind===LEAD_CAPTURE,p=m&&u.length>0,x=m&&e.confirmLabel||i.actionConfirm,h=m&&e.rejectLabel||i.actionDismiss,f=null!==r;return _jsxs(Card,{variant:"outline",padding:"sm",children:[_jsxs(View,{style:{gap:n.space.sm},children:[_jsx(Text,{variant:"label",children:e.title}),e.lines.map(e=>{if(!m)return _jsx(Text,{variant:"bodySmall",children:e},e);const{term:t,detail:i}=splitLine(e);return _jsxs(View,{style:{flexDirection:"row",flexWrap:"wrap",gap:n.space.xs},children:[_jsx(Text,{variant:"label",children:t}),null!==i?_jsx(Text,{variant:"bodySmall",children:i}):null]},e)}),m&&e.consentText?_jsx(Text,{variant:"caption",color:"secondary",children:inlineNodes(parseInline(e.consentText),n)}):null,"Pending"===e.state?_jsxs(_Fragment,{children:[""!==s?_jsx(Text,{variant:"bodySmall",color:"danger",accessibilityLiveRegion:"polite",children:s}):null,_jsxs(View,{style:{flexDirection:"row",flexWrap:"wrap",gap:n.space.sm},children:[_jsx(Button,{label:"confirm"===r?i.actionWorking:x,loading:"confirm"===r,disabled:f,onPress:()=>{run("confirm",()=>t.confirmAction(e.actionId))}}),_jsx(Button,{label:h,variant:"ghost",disabled:f,onPress:()=>{run("reject",()=>t.rejectAction(e.actionId))}})]})]}):_jsx(Text,{variant:"bodySmall",color:"Done"===e.state||"Confirmed"===e.state||"Repeat"===e.state?"success":"secondary",children:statusLine(e,i)}),p?_jsx(Button,{label:i.editSomething,variant:"ghost",disabled:f||"Pending"!==e.state,onPress:()=>d(!0)}):null,e.note?_jsx(Text,{variant:"caption",color:"secondary",children:e.note}):null]}),p?_jsx(OptionSheet,{open:c,onClose:()=>d(!1),title:i.editSomething,options:u,onChange:(e,n)=>{d(!1),t.chooseQuickReply({id:`lead.edit:${String(n.value)}`,label:n.label,action:"Send",target:null,navigateAfterMs:null,icon:null,variant:null})}}):null]})}export function ActionPart(e){const{part:t,message:n,turn:i}=e;if("Action"!==t.kind){const e={kind:"Notice",code:"NeedsNewerApp",text:i.labels.needsNewerApp};return _jsx(NoticePart,{part:e,message:n,turn:i})}return _jsx(ActionBody,{part:t,turn:i},t.actionId)}
|
|
@@ -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);
|
|
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())})}
|
|
@@ -2,6 +2,7 @@ import type { ChatLiveMessage } from "@webority/chat-core";
|
|
|
2
2
|
/** Moves screen-reader focus to a view. findNodeHandle throws on react-native-web, so the browser focuses the element itself. */
|
|
3
3
|
export declare function focusForAccessibility(node: unknown): void;
|
|
4
4
|
export declare function messageSignature(message: ChatLiveMessage): string;
|
|
5
|
+
export declare function openExternalUrl(url: string): void;
|
|
5
6
|
export declare function defaultOpenTarget(target: string): void;
|
|
6
7
|
export declare const WEB_STRONG: object;
|
|
7
8
|
//# sourceMappingURL=chatShared.d.ts.map
|
|
@@ -2,6 +2,7 @@ import type { ChatLiveMessage } from "@webority/chat-core";
|
|
|
2
2
|
/** Moves screen-reader focus to a view. findNodeHandle throws on react-native-web, so the browser focuses the element itself. */
|
|
3
3
|
export declare function focusForAccessibility(node: unknown): void;
|
|
4
4
|
export declare function messageSignature(message: ChatLiveMessage): string;
|
|
5
|
+
export declare function openExternalUrl(url: string): void;
|
|
5
6
|
export declare function defaultOpenTarget(target: string): void;
|
|
6
7
|
export declare const WEB_STRONG: object;
|
|
7
8
|
//# sourceMappingURL=chatShared.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webority/mobile-chat",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.140.1",
|
|
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,10 +42,10 @@
|
|
|
42
42
|
"!**/*.map"
|
|
43
43
|
],
|
|
44
44
|
"peerDependencies": {
|
|
45
|
-
"@webority/chat-core": "0.
|
|
46
|
-
"@webority/markdown-core": "^0.
|
|
47
|
-
"@webority/mobile-core": "^0.
|
|
48
|
-
"@webority/mobile-ui": "^0.
|
|
45
|
+
"@webority/chat-core": "0.140.1",
|
|
46
|
+
"@webority/markdown-core": "^0.146.0",
|
|
47
|
+
"@webority/mobile-core": "^0.146.0",
|
|
48
|
+
"@webority/mobile-ui": "^0.146.0",
|
|
49
49
|
"expo-audio": ">=57.0.0",
|
|
50
50
|
"expo-file-system": ">=57.0.0",
|
|
51
51
|
"react": "^19.1.0",
|
|
@@ -98,11 +98,11 @@
|
|
|
98
98
|
"@testing-library/react-native": "12.9.0",
|
|
99
99
|
"@types/jest": "29.5.14",
|
|
100
100
|
"@types/react": "19.2.18",
|
|
101
|
-
"@webority/canvas-kit": "0.
|
|
102
|
-
"@webority/chat-core": "0.
|
|
103
|
-
"@webority/markdown-core": "0.
|
|
104
|
-
"@webority/mobile-core": "0.
|
|
105
|
-
"@webority/mobile-ui": "0.
|
|
101
|
+
"@webority/canvas-kit": "0.146.2",
|
|
102
|
+
"@webority/chat-core": "0.140.1",
|
|
103
|
+
"@webority/markdown-core": "0.146.2",
|
|
104
|
+
"@webority/mobile-core": "0.146.2",
|
|
105
|
+
"@webority/mobile-ui": "0.146.2",
|
|
106
106
|
"babel-jest": "29.7.0",
|
|
107
107
|
"expo": "57.0.31",
|
|
108
108
|
"expo-application": "57.0.3",
|