@davi-ai/retorik-framework 4.0.4 → 5.0.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.
Files changed (84) hide show
  1. package/README.md +13 -0
  2. package/dist/{AttachmentDetail.637ad44f.js → AttachmentDetail.3f9c113d.js} +15 -6
  3. package/dist/AttachmentDetail.3f9c113d.js.map +1 -0
  4. package/dist/{AttachmentDetail.83788045.js → AttachmentDetail.57c5579a.js} +15 -6
  5. package/dist/AttachmentDetail.57c5579a.js.map +1 -0
  6. package/dist/{CustomView.bf84bdf3.js → CustomView.6b96f53f.js} +8 -4
  7. package/dist/CustomView.6b96f53f.js.map +1 -0
  8. package/dist/{CustomView.9930c671.js → CustomView.b32a608f.js} +8 -4
  9. package/dist/CustomView.b32a608f.js.map +1 -0
  10. package/dist/{Emergency.1112c09f.js → Emergency.43605d14.js} +11 -2
  11. package/dist/Emergency.43605d14.js.map +1 -0
  12. package/dist/{Emergency.d5810ff2.js → Emergency.f1287bd5.js} +11 -2
  13. package/dist/Emergency.f1287bd5.js.map +1 -0
  14. package/dist/FullScreenImage.17df27bf.js.map +1 -1
  15. package/dist/FullScreenImage.99e19e10.js.map +1 -1
  16. package/dist/{HistoryList.3b4b1ffb.js → HistoryList.c19556a7.js} +8 -2
  17. package/dist/HistoryList.c19556a7.js.map +1 -0
  18. package/dist/{HistoryList.e5c01f21.js → HistoryList.e7262d62.js} +8 -2
  19. package/dist/HistoryList.e7262d62.js.map +1 -0
  20. package/dist/{LanguageChoice.1d866cfa.js → LanguageChoice.54fae1dc.js} +19 -8
  21. package/dist/LanguageChoice.54fae1dc.js.map +1 -0
  22. package/dist/{LanguageChoice.cce361a3.js → LanguageChoice.6e8b74f6.js} +19 -8
  23. package/dist/LanguageChoice.6e8b74f6.js.map +1 -0
  24. package/dist/LittleWeatherContainer.7e41105e.js.map +1 -1
  25. package/dist/LittleWeatherContainer.ee087e22.js.map +1 -1
  26. package/dist/{MapContainer.14c28128.js → MapContainer.25c8f4b4.js} +20 -5
  27. package/dist/MapContainer.25c8f4b4.js.map +1 -0
  28. package/dist/{MapContainer.f22ad81f.js → MapContainer.d00ab5b2.js} +20 -5
  29. package/dist/MapContainer.d00ab5b2.js.map +1 -0
  30. package/dist/{NewsContainer.d9de093c.js → NewsContainer.a39630c3.js} +33 -26
  31. package/dist/NewsContainer.a39630c3.js.map +1 -0
  32. package/dist/{NewsContainer.463e74de.js → NewsContainer.ec15c3bb.js} +33 -26
  33. package/dist/NewsContainer.ec15c3bb.js.map +1 -0
  34. package/dist/PrintingPreview.375e62b0.js.map +1 -1
  35. package/dist/PrintingPreview.c0ca7706.js.map +1 -1
  36. package/dist/RecognitionManager.c58b8a3d.js +298 -0
  37. package/dist/RecognitionManager.c58b8a3d.js.map +1 -0
  38. package/dist/RecognitionManager.cdfb39fc.js +314 -0
  39. package/dist/RecognitionManager.cdfb39fc.js.map +1 -0
  40. package/dist/SpiritEngineWrapper.21ea10d4.js.map +1 -1
  41. package/dist/SpiritEngineWrapper.39627300.js.map +1 -1
  42. package/dist/SynthesisPonyfillManager.10888d6d.js +888 -0
  43. package/dist/SynthesisPonyfillManager.10888d6d.js.map +1 -0
  44. package/dist/SynthesisPonyfillManager.f9f9a915.js +920 -0
  45. package/dist/SynthesisPonyfillManager.f9f9a915.js.map +1 -0
  46. package/dist/{ThreeJsWrapper.dd4906ff.js → ThreeJsWrapper.0285d280.js} +24 -12
  47. package/dist/ThreeJsWrapper.0285d280.js.map +1 -0
  48. package/dist/{ThreeJsWrapper.c02a077f.js → ThreeJsWrapper.ad746197.js} +24 -11
  49. package/dist/ThreeJsWrapper.ad746197.js.map +1 -0
  50. package/dist/{VeilleManager.f3bafdec.js → VeilleManager.0b3f2454.js} +11 -13
  51. package/dist/VeilleManager.0b3f2454.js.map +1 -0
  52. package/dist/{VeilleManager.85967e7c.js → VeilleManager.340a7825.js} +11 -13
  53. package/dist/VeilleManager.340a7825.js.map +1 -0
  54. package/dist/{Weather.7e945307.js → Weather.abc13d88.js} +9 -3
  55. package/dist/Weather.abc13d88.js.map +1 -0
  56. package/dist/{Weather.e81b7205.js → Weather.b9d9f82e.js} +9 -3
  57. package/dist/Weather.b9d9f82e.js.map +1 -0
  58. package/dist/index.d.ts +21 -951
  59. package/dist/index.d.ts.map +1 -1
  60. package/dist/index.js +52952 -33750
  61. package/dist/index.js.map +1 -1
  62. package/dist/index.modern.js +53468 -34269
  63. package/dist/index.modern.js.map +1 -1
  64. package/package.json +21 -21
  65. package/dist/AttachmentDetail.637ad44f.js.map +0 -1
  66. package/dist/AttachmentDetail.83788045.js.map +0 -1
  67. package/dist/CustomView.9930c671.js.map +0 -1
  68. package/dist/CustomView.bf84bdf3.js.map +0 -1
  69. package/dist/Emergency.1112c09f.js.map +0 -1
  70. package/dist/Emergency.d5810ff2.js.map +0 -1
  71. package/dist/HistoryList.3b4b1ffb.js.map +0 -1
  72. package/dist/HistoryList.e5c01f21.js.map +0 -1
  73. package/dist/LanguageChoice.1d866cfa.js.map +0 -1
  74. package/dist/LanguageChoice.cce361a3.js.map +0 -1
  75. package/dist/MapContainer.14c28128.js.map +0 -1
  76. package/dist/MapContainer.f22ad81f.js.map +0 -1
  77. package/dist/NewsContainer.463e74de.js.map +0 -1
  78. package/dist/NewsContainer.d9de093c.js.map +0 -1
  79. package/dist/ThreeJsWrapper.c02a077f.js.map +0 -1
  80. package/dist/ThreeJsWrapper.dd4906ff.js.map +0 -1
  81. package/dist/VeilleManager.85967e7c.js.map +0 -1
  82. package/dist/VeilleManager.f3bafdec.js.map +0 -1
  83. package/dist/Weather.7e945307.js.map +0 -1
  84. package/dist/Weather.e81b7205.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,MAAM,wCAAkB;AAExB,MAAM,2CAAqB;IACzB,MAAM,WAAW,CAAA,GAAA,kBAAU;IAC3B,MAAM,SAAS,CAAA,GAAA,kBAAU,EAAE,CAAC,QAA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Ae,EAAE,MAAM;oBAC1B,IAAI,4BAA4B,SAAS,CAAA,GAAA,WAAG,EAAE,KAAK,EACjD,SAAS,OAAO,GAAG,WAAW;wBAC5B,SAAS,iBAAiB,CAAC,+BAA+B;oBAC5D,GAAG;oBAEL,SAAS,CAAA,GAAA,mBAAW,EAAE,MAAM,CAAC,yBAAyB,CAAC;oBACvD;YAEJ;QACF;IACF,GAAG;QAAC;KAAuB;IAE3B,qBAAO,gBAAC,CAAA,GAAA,YAAI,EAAE,QAAQ;AACxB;IAEA,2CAAe;;;;;;;;ACrRf,MAAM,gDAA0B;IAC9B,IAAI;QACF,OAAO,UAAU,YAAY,CAC1B,YAAY,CAAC;YAAE,OAAO;QAAK,GAC3B,IAAI,CACH,CAAC;YACC,OAAO,SAAS,CAAA,GAAA,uBAAe,EAAE,OAAO,GAAG,CAAA,GAAA,uBAAe,EAAE,OAAO;QACrE,GACA,CAAC;YACC,QAAQ,GAAG,CACT,wDACA;YAEF,OAAO,CAAA,GAAA,uBAAe,EAAE,OAAO;QACjC,GAED,KAAK,CAAC,CAAC;YACN,QAAQ,GAAG,CACT,wDACA;YAEF,OAAO,CAAA,GAAA,uBAAe,EAAE,KAAK;QAC/B;IACJ,EAAE,OAAO,OAAO;QACd,QAAQ,GAAG,CAAC,wDAAwD;QACpE,OAAO,CAAA,GAAA,uBAAe,EAAE,KAAK;IAC/B;AACF;IAEA,2CAAe","sources":["src/components/Speech/RecognitionManager.tsx","src/utils/getMicrophonePermission.ts"],"sourcesContent":["import React, { useEffect, useRef, useState } from 'react'\r\nimport { createSpeechRecognitionPonyfill, SpeechGrammarList } from '@davi-ai/web-speech-cognitive-services-davi'\r\nimport type { PonyfillOptions, SpeechRecognitionPonyfillType, SpeechRecognitionProps, SpeechRecognitionResultList, SpeechRecognitionResultListItem } from '@davi-ai/web-speech-cognitive-services-davi'\r\nimport { useSelector, useDispatch } from 'react-redux'\r\nimport { RootState, storeActions, Mode, PermissionStatus, RecognitionState, Routes } from '../../store'\r\nimport getMicrophonePermission from '../../utils/getMicrophonePermission'\r\n\r\nconst timeoutDuration = 1000\r\n\r\nconst RecognitionManager = (): React.JSX.Element => {\r\n const dispatch = useDispatch()\r\n const locale = useSelector((state: RootState) => state.localeReducer.locale)\r\n const mode = useSelector((state: RootState) => state.speechReducer.mode)\r\n const appAvailable = useSelector((state: RootState) => state.retorikReducer.appAvailable)\r\n const loaderClosed = useSelector((state: RootState) => state.retorikReducer.loaderClosed)\r\n const agentData = useSelector((state: RootState) => state.retorikReducer.agentData)\r\n const delay = useSelector((state: RootState) => state.retorikReducer.submitDelayBeforeSendingMessage)\r\n const speechRecognitionOptions = useSelector((state: RootState) => state.retorikReducer.configuration.speechRecognitionOptions)\r\n const ponyfillCredentials = useSelector((state: RootState) => state.speechReducer.ponyfillCredentials)\r\n const useContinuousRecognition = useSelector((state: RootState) => state.speechReducer.useContinuousRecognition)\r\n const activeRecognitionState = useSelector((state: RootState) => state.speechReducer.activeRecognitionState)\r\n const lastRecognitionInterim = useSelector((state: RootState) => state.speechReducer.lastRecognitionInterim)\r\n const speechRecognitionDynamicGrammars = useSelector((state: RootState) => state.speechReducer.speechRecognitionDynamicGrammars)\r\n const route = useSelector((state: RootState) => state.viewReducer.route)\r\n\r\n const [ponyfill, setPonyfill] = useState<SpeechRecognitionPonyfillType | null>(null)\r\n const [recognitionAllowed, setRecognitionAllowed] = useState<boolean>(false)\r\n const [ponyfillReady, setPonyfillReady] = useState<boolean>(false)\r\n\r\n const activeModeRef = useRef<RecognitionState | undefined>(undefined)\r\n const timerRef = useRef<NodeJS.Timeout | null>(null)\r\n const localeRef = useRef<string | undefined>(undefined)\r\n\r\n const getCommonAndLocalizedWakeWords = (currentLocale: string, agentName?: string): Array<string> => {\r\n let commonAndlocalizedWakeWords: Array<string> = []\r\n if (speechRecognitionOptions?.wakeWords) {\r\n if (speechRecognitionOptions.wakeWords.common) {\r\n commonAndlocalizedWakeWords = [...speechRecognitionOptions.wakeWords.common]\r\n }\r\n\r\n if (speechRecognitionOptions.wakeWords.localized) {\r\n const localizedWakeWords = speechRecognitionOptions.wakeWords.localized[currentLocale] || []\r\n localizedWakeWords.length && (commonAndlocalizedWakeWords = [...commonAndlocalizedWakeWords, ...localizedWakeWords])\r\n }\r\n }\r\n\r\n // Add agent's name to wake words\r\n agentName && (commonAndlocalizedWakeWords = [...commonAndlocalizedWakeWords, agentName])\r\n\r\n return commonAndlocalizedWakeWords\r\n }\r\n\r\n const getCommonAndLocalizedGrammars = (currentLocale: string): Array<string> => {\r\n let commonAndlocalizedGrammars: Array<string> = []\r\n if (speechRecognitionOptions?.grammars) {\r\n if (speechRecognitionOptions.grammars.common) {\r\n commonAndlocalizedGrammars = [...speechRecognitionOptions.grammars.common]\r\n }\r\n\r\n if (speechRecognitionOptions.grammars.localized) {\r\n const localizedGrammars = speechRecognitionOptions.grammars.localized[currentLocale] || []\r\n localizedGrammars.length && (commonAndlocalizedGrammars = [...commonAndlocalizedGrammars, ...localizedGrammars])\r\n }\r\n }\r\n\r\n return commonAndlocalizedGrammars\r\n }\r\n\r\n const askPermission = (): void => {\r\n if (recognitionAllowed) {\r\n ponyfill?.speechRecognition.start()\r\n } else {\r\n getMicrophonePermission()\r\n .then((permission) => {\r\n setRecognitionAllowed(permission === PermissionStatus.allowed)\r\n })\r\n .catch(console.log)\r\n }\r\n }\r\n\r\n useEffect(() => {\r\n // Clear data on component unmount\r\n return () => {\r\n timerRef?.current && clearTimeout(timerRef.current)\r\n ponyfill?.speechRecognition?.abort?.()\r\n }\r\n }, [])\r\n\r\n useEffect(() => {\r\n recognitionAllowed && useContinuousRecognition && ponyfill?.speechRecognition.start()\r\n }, [recognitionAllowed])\r\n\r\n useEffect(() => {\r\n if (ponyfillCredentials && locale && agentData) {\r\n let currentPonyfill = ponyfill\r\n if (locale !== localeRef.current) {\r\n localeRef.current = locale\r\n // We create the ponyfill if it isn't created yet. We recreate a new one if we are using custom endpoints for speech recognition.\r\n if (!ponyfill || ponyfillCredentials?.speechRecognitionHostnamesRecord) {\r\n // Check if we need to use a custom endpoint from speechRecognitionHostnamesRecord\r\n const speechRecognitionHostname = ponyfillCredentials?.speechRecognitionHostnamesRecord\r\n ? ponyfillCredentials.speechRecognitionHostnamesRecord[locale] || Object.values(ponyfillCredentials.speechRecognitionHostnamesRecord)[0]\r\n : undefined\r\n\r\n const options: SpeechRecognitionProps = {\r\n autoStart: false,\r\n continuous: useContinuousRecognition,\r\n interimResults: true,\r\n grammarsList: getCommonAndLocalizedGrammars(locale),\r\n lang: locale,\r\n passive: useContinuousRecognition,\r\n wakeWords: getCommonAndLocalizedWakeWords(locale),\r\n debug: false,\r\n timerBeforeSpeechEnd: speechRecognitionOptions?.timerBeforeSpeechEnd\r\n }\r\n\r\n const processedCredentials: PonyfillOptions = {\r\n credentials: speechRecognitionHostname\r\n ? {\r\n region: undefined,\r\n subscriptionKey: ponyfillCredentials.subscriptionKey || 'mandatory_subscription_key',\r\n speechRecognitionHostname: speechRecognitionHostname,\r\n speechSynthesisHostname: 'mandatory_synthesis_host_name'\r\n }\r\n : {\r\n region: ponyfillCredentials.region,\r\n subscriptionKey: ponyfillCredentials.subscriptionKey,\r\n authorizationToken: ponyfillCredentials.authorizationToken\r\n }\r\n }\r\n\r\n // Abort current recognition before setting the new recognition ponyfill if there is a need to\r\n currentPonyfill?.speechRecognition?.abort?.()\r\n currentPonyfill = createSpeechRecognitionPonyfill(processedCredentials, options)\r\n } else if (currentPonyfill) {\r\n // Set wakeworkds\r\n currentPonyfill.speechRecognition.wakeWords = getCommonAndLocalizedWakeWords(locale, agentData?.name)\r\n // Set language\r\n activeRecognitionState === RecognitionState.Listening ? currentPonyfill?.speechRecognition.changeLanguage(locale) : (currentPonyfill.speechRecognition.lang = locale)\r\n }\r\n }\r\n\r\n if (currentPonyfill) {\r\n // Set grammar list\r\n const grammarList = new SpeechGrammarList()\r\n grammarList.phrases = getCommonAndLocalizedGrammars(locale)\r\n if (speechRecognitionDynamicGrammars.length) {\r\n speechRecognitionDynamicGrammars.forEach((grammar) => {\r\n !grammarList.phrases.includes(grammar) && grammarList.phrases.push(grammar)\r\n })\r\n }\r\n\r\n if (agentData?.name) {\r\n // Add raw name\r\n !grammarList.phrases.includes(agentData.name) && grammarList.phrases.push(agentData.name)\r\n // Add lower-cased name\r\n !grammarList.phrases.includes(agentData.name.toLocaleLowerCase(locale)) && grammarList.phrases.push(agentData.name.toLocaleLowerCase(locale))\r\n }\r\n currentPonyfill.speechRecognition.grammars = grammarList\r\n\r\n setPonyfill(currentPonyfill)\r\n }\r\n }\r\n }, [ponyfillCredentials, locale, speechRecognitionDynamicGrammars, agentData])\r\n\r\n /**\r\n * Abort recognition if we are not on the 'home' page\r\n */\r\n useEffect(() => {\r\n route !== Routes.Home && dispatch(storeActions.speech.setActiveRecognitionState(RecognitionState.Closed))\r\n }, [route])\r\n\r\n useEffect(() => {\r\n if (ponyfill && appAvailable && loaderClosed) {\r\n if (ponyfill.speechRecognition) {\r\n ponyfill.speechRecognition.onstart = () => {\r\n dispatch(storeActions.speech.setActiveRecognitionState(RecognitionState.Listening))\r\n }\r\n\r\n // onend callback is called only whithout using passive speech recognition\r\n ponyfill.speechRecognition.onend = () => {\r\n activeModeRef.current !== RecognitionState.Closed && dispatch(storeActions.speech.setActiveRecognitionState(RecognitionState.Closing))\r\n }\r\n\r\n ponyfill.speechRecognition.onabort = () => {\r\n dispatch(storeActions.speech.setActiveRecognitionState(RecognitionState.Closed))\r\n }\r\n\r\n ponyfill.speechRecognition.onwakeup = () => {\r\n if (activeModeRef.current === RecognitionState.Closed) {\r\n console.log('Retorik Framework > wake word found, trying to open microphone')\r\n activeModeRef.current === RecognitionState.Closed && dispatch(storeActions.speech.toggleMicrophone(false))\r\n } else {\r\n console.log('Retorik Framework > wake word found, but microphone not ready')\r\n }\r\n }\r\n\r\n ponyfill.speechRecognition.onresult = (result: SpeechRecognitionResultList | Array<SpeechRecognitionResultListItem>) => {\r\n const lastMessage: string | null = result.length ? result[result.length - 1].transcript : null\r\n // Only get result in Active mode\r\n if (lastMessage && activeModeRef.current === RecognitionState.Listening) {\r\n dispatch(storeActions.speech.setLastRecognitionInterim(lastMessage))\r\n }\r\n }\r\n\r\n setPonyfillReady(true)\r\n }\r\n }\r\n }, [ponyfill, appAvailable, loaderClosed])\r\n\r\n useEffect(() => {\r\n if (ponyfillReady && mode === Mode.vocal) {\r\n // Start passive recognition if not done yet\r\n useContinuousRecognition && !ponyfill?.speechRecognition.started && askPermission()\r\n }\r\n }, [mode, ponyfillReady])\r\n\r\n const togglePassiveToActive = (): void => {\r\n if (ponyfill?.speechRecognition.started) {\r\n ponyfill.speechRecognition.toggleContinuousPassiveToActive()\r\n } else {\r\n if (ponyfill) {\r\n ponyfill.speechRecognition.passive = false\r\n ponyfill.speechRecognition.continuous = false\r\n ponyfill.speechRecognition.start()\r\n }\r\n }\r\n }\r\n\r\n useEffect(() => {\r\n activeModeRef.current = activeRecognitionState\r\n\r\n if (ponyfill?.speechRecognition && appAvailable && loaderClosed) {\r\n timerRef?.current && clearTimeout(timerRef.current)\r\n switch (activeRecognitionState) {\r\n // Do nothing if we are in a transition state\r\n case RecognitionState.Initializing: {\r\n useContinuousRecognition ? togglePassiveToActive() : ponyfill.speechRecognition.start()\r\n break\r\n }\r\n case RecognitionState.Listening:\r\n break\r\n case RecognitionState.Closing: {\r\n if (lastRecognitionInterim) {\r\n if (!delay) {\r\n timerRef.current = setTimeout(() => {\r\n dispatch(storeActions.directline.sendMessage({ text: lastRecognitionInterim }))\r\n\r\n dispatch(storeActions.speech.setActiveRecognitionState(RecognitionState.Closed))\r\n }, timeoutDuration)\r\n }\r\n } else {\r\n dispatch(storeActions.speech.setActiveRecognitionState(RecognitionState.Closed))\r\n }\r\n break\r\n }\r\n case RecognitionState.ForceClosing: {\r\n dispatch(storeActions.speech.setLastRecognitionInterim(''))\r\n\r\n // Let's abort the current recognition\r\n ponyfill.speechRecognition.started ? ponyfill.speechRecognition.abort?.() : dispatch(storeActions.speech.setActiveRecognitionState(RecognitionState.Closed))\r\n break\r\n }\r\n case RecognitionState.Closed: {\r\n if (useContinuousRecognition && mode === Mode.vocal) {\r\n timerRef.current = setTimeout(() => {\r\n ponyfill.speechRecognition.toggleContinuousActiveToPassive()\r\n }, timeoutDuration)\r\n }\r\n dispatch(storeActions.speech.setLastRecognitionInterim(''))\r\n break\r\n }\r\n }\r\n }\r\n }, [activeRecognitionState])\r\n\r\n return <React.Fragment />\r\n}\r\n\r\nexport default RecognitionManager\r\n","import { PermissionStatus } from '../store'\r\n\r\nconst getMicrophonePermission = async (): Promise<PermissionStatus> => {\r\n try {\r\n return navigator.mediaDevices\r\n .getUserMedia({ audio: true })\r\n .then(\r\n (stream) => {\r\n return stream ? PermissionStatus.allowed : PermissionStatus.refused\r\n },\r\n (reason) => {\r\n console.log(\r\n 'Retorik Framework > microphone permission refused : ',\r\n reason\r\n )\r\n return PermissionStatus.refused\r\n }\r\n )\r\n .catch((error) => {\r\n console.log(\r\n 'Retorik Framework > microphone permission refused : ',\r\n error\r\n )\r\n return PermissionStatus.error\r\n })\r\n } catch (error) {\r\n console.log('Retorik Framework > microphone permission refused : ', error)\r\n return PermissionStatus.error\r\n }\r\n}\r\n\r\nexport default getMicrophonePermission\r\n"],"names":[],"version":3,"file":"RecognitionManager.c58b8a3d.js.map"}
@@ -0,0 +1,314 @@
1
+ var $b6dTP$reactjsxruntime = require("react/jsx-runtime");
2
+ var $b6dTP$react = require("react");
3
+ var $b6dTP$daviaiwebspeechcognitiveservicesdavi = require("@davi-ai/web-speech-cognitive-services-davi");
4
+ var $b6dTP$reactredux = require("react-redux");
5
+
6
+
7
+ function $parcel$interopDefault(a) {
8
+ return a && a.__esModule ? a.default : a;
9
+ }
10
+
11
+ function $parcel$defineInteropFlag(a) {
12
+ Object.defineProperty(a, '__esModule', {value: true, configurable: true});
13
+ }
14
+
15
+ function $parcel$export(e, n, v, s) {
16
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
17
+ }
18
+
19
+ var $parcel$global =
20
+ typeof globalThis !== 'undefined'
21
+ ? globalThis
22
+ : typeof self !== 'undefined'
23
+ ? self
24
+ : typeof window !== 'undefined'
25
+ ? window
26
+ : typeof global !== 'undefined'
27
+ ? global
28
+ : {};
29
+ var parcelRequire = $parcel$global["parcelRequirea39d"];
30
+ var parcelRegister = parcelRequire.register;
31
+ parcelRegister("fBoAz", function(module, exports) {
32
+
33
+ $parcel$defineInteropFlag(module.exports);
34
+
35
+ $parcel$export(module.exports, "default", () => $b0722e4118e770aa$export$2e2bcd8739ae039);
36
+
37
+
38
+
39
+
40
+
41
+ var $kpW3P = parcelRequire("kpW3P");
42
+
43
+ var $4vSkU = parcelRequire("4vSkU");
44
+ const $b0722e4118e770aa$var$timeoutDuration = 1000;
45
+ const $b0722e4118e770aa$var$RecognitionManager = ()=>{
46
+ const dispatch = (0, $b6dTP$reactredux.useDispatch)();
47
+ const locale = (0, $b6dTP$reactredux.useSelector)((state)=>state.localeReducer.locale);
48
+ const mode = (0, $b6dTP$reactredux.useSelector)((state)=>state.speechReducer.mode);
49
+ const appAvailable = (0, $b6dTP$reactredux.useSelector)((state)=>state.retorikReducer.appAvailable);
50
+ const loaderClosed = (0, $b6dTP$reactredux.useSelector)((state)=>state.retorikReducer.loaderClosed);
51
+ const agentData = (0, $b6dTP$reactredux.useSelector)((state)=>state.retorikReducer.agentData);
52
+ const delay = (0, $b6dTP$reactredux.useSelector)((state)=>state.retorikReducer.submitDelayBeforeSendingMessage);
53
+ const speechRecognitionOptions = (0, $b6dTP$reactredux.useSelector)((state)=>state.retorikReducer.configuration.speechRecognitionOptions);
54
+ const ponyfillCredentials = (0, $b6dTP$reactredux.useSelector)((state)=>state.speechReducer.ponyfillCredentials);
55
+ const useContinuousRecognition = (0, $b6dTP$reactredux.useSelector)((state)=>state.speechReducer.useContinuousRecognition);
56
+ const activeRecognitionState = (0, $b6dTP$reactredux.useSelector)((state)=>state.speechReducer.activeRecognitionState);
57
+ const lastRecognitionInterim = (0, $b6dTP$reactredux.useSelector)((state)=>state.speechReducer.lastRecognitionInterim);
58
+ const speechRecognitionDynamicGrammars = (0, $b6dTP$reactredux.useSelector)((state)=>state.speechReducer.speechRecognitionDynamicGrammars);
59
+ const route = (0, $b6dTP$reactredux.useSelector)((state)=>state.viewReducer.route);
60
+ const [ponyfill, setPonyfill] = (0, $b6dTP$react.useState)(null);
61
+ const [recognitionAllowed, setRecognitionAllowed] = (0, $b6dTP$react.useState)(false);
62
+ const [ponyfillReady, setPonyfillReady] = (0, $b6dTP$react.useState)(false);
63
+ const activeModeRef = (0, $b6dTP$react.useRef)(undefined);
64
+ const timerRef = (0, $b6dTP$react.useRef)(null);
65
+ const localeRef = (0, $b6dTP$react.useRef)(undefined);
66
+ const getCommonAndLocalizedWakeWords = (currentLocale, agentName)=>{
67
+ let commonAndlocalizedWakeWords = [];
68
+ if (speechRecognitionOptions === null || speechRecognitionOptions === void 0 ? void 0 : speechRecognitionOptions.wakeWords) {
69
+ if (speechRecognitionOptions.wakeWords.common) commonAndlocalizedWakeWords = [
70
+ ...speechRecognitionOptions.wakeWords.common
71
+ ];
72
+ if (speechRecognitionOptions.wakeWords.localized) {
73
+ const localizedWakeWords = speechRecognitionOptions.wakeWords.localized[currentLocale] || [];
74
+ localizedWakeWords.length && (commonAndlocalizedWakeWords = [
75
+ ...commonAndlocalizedWakeWords,
76
+ ...localizedWakeWords
77
+ ]);
78
+ }
79
+ }
80
+ // Add agent's name to wake words
81
+ agentName && (commonAndlocalizedWakeWords = [
82
+ ...commonAndlocalizedWakeWords,
83
+ agentName
84
+ ]);
85
+ return commonAndlocalizedWakeWords;
86
+ };
87
+ const getCommonAndLocalizedGrammars = (currentLocale)=>{
88
+ let commonAndlocalizedGrammars = [];
89
+ if (speechRecognitionOptions === null || speechRecognitionOptions === void 0 ? void 0 : speechRecognitionOptions.grammars) {
90
+ if (speechRecognitionOptions.grammars.common) commonAndlocalizedGrammars = [
91
+ ...speechRecognitionOptions.grammars.common
92
+ ];
93
+ if (speechRecognitionOptions.grammars.localized) {
94
+ const localizedGrammars = speechRecognitionOptions.grammars.localized[currentLocale] || [];
95
+ localizedGrammars.length && (commonAndlocalizedGrammars = [
96
+ ...commonAndlocalizedGrammars,
97
+ ...localizedGrammars
98
+ ]);
99
+ }
100
+ }
101
+ return commonAndlocalizedGrammars;
102
+ };
103
+ const askPermission = ()=>{
104
+ if (recognitionAllowed) ponyfill === null || ponyfill === void 0 ? void 0 : ponyfill.speechRecognition.start();
105
+ else (0, $4vSkU.default)().then((permission)=>{
106
+ setRecognitionAllowed(permission === (0, $kpW3P.PermissionStatus).allowed);
107
+ }).catch(console.log);
108
+ };
109
+ (0, $b6dTP$react.useEffect)(()=>{
110
+ // Clear data on component unmount
111
+ return ()=>{
112
+ var _ponyfill_speechRecognition_abort, _ponyfill_speechRecognition;
113
+ (timerRef === null || timerRef === void 0 ? void 0 : timerRef.current) && clearTimeout(timerRef.current);
114
+ ponyfill === null || ponyfill === void 0 ? void 0 : (_ponyfill_speechRecognition = ponyfill.speechRecognition) === null || _ponyfill_speechRecognition === void 0 ? void 0 : (_ponyfill_speechRecognition_abort = _ponyfill_speechRecognition.abort) === null || _ponyfill_speechRecognition_abort === void 0 ? void 0 : _ponyfill_speechRecognition_abort.call(_ponyfill_speechRecognition);
115
+ };
116
+ }, []);
117
+ (0, $b6dTP$react.useEffect)(()=>{
118
+ recognitionAllowed && useContinuousRecognition && (ponyfill === null || ponyfill === void 0 ? void 0 : ponyfill.speechRecognition.start());
119
+ }, [
120
+ recognitionAllowed
121
+ ]);
122
+ (0, $b6dTP$react.useEffect)(()=>{
123
+ if (ponyfillCredentials && locale && agentData) {
124
+ let currentPonyfill = ponyfill;
125
+ if (locale !== localeRef.current) {
126
+ localeRef.current = locale;
127
+ // We create the ponyfill if it isn't created yet. We recreate a new one if we are using custom endpoints for speech recognition.
128
+ if (!ponyfill || (ponyfillCredentials === null || ponyfillCredentials === void 0 ? void 0 : ponyfillCredentials.speechRecognitionHostnamesRecord)) {
129
+ var // Abort current recognition before setting the new recognition ponyfill if there is a need to
130
+ _currentPonyfill_speechRecognition_abort, _currentPonyfill_speechRecognition;
131
+ // Check if we need to use a custom endpoint from speechRecognitionHostnamesRecord
132
+ const speechRecognitionHostname = (ponyfillCredentials === null || ponyfillCredentials === void 0 ? void 0 : ponyfillCredentials.speechRecognitionHostnamesRecord) ? ponyfillCredentials.speechRecognitionHostnamesRecord[locale] || Object.values(ponyfillCredentials.speechRecognitionHostnamesRecord)[0] : undefined;
133
+ const options = {
134
+ autoStart: false,
135
+ continuous: useContinuousRecognition,
136
+ interimResults: true,
137
+ grammarsList: getCommonAndLocalizedGrammars(locale),
138
+ lang: locale,
139
+ passive: useContinuousRecognition,
140
+ wakeWords: getCommonAndLocalizedWakeWords(locale),
141
+ debug: false,
142
+ timerBeforeSpeechEnd: speechRecognitionOptions === null || speechRecognitionOptions === void 0 ? void 0 : speechRecognitionOptions.timerBeforeSpeechEnd
143
+ };
144
+ const processedCredentials = {
145
+ credentials: speechRecognitionHostname ? {
146
+ region: undefined,
147
+ subscriptionKey: ponyfillCredentials.subscriptionKey || 'mandatory_subscription_key',
148
+ speechRecognitionHostname: speechRecognitionHostname,
149
+ speechSynthesisHostname: 'mandatory_synthesis_host_name'
150
+ } : {
151
+ region: ponyfillCredentials.region,
152
+ subscriptionKey: ponyfillCredentials.subscriptionKey,
153
+ authorizationToken: ponyfillCredentials.authorizationToken
154
+ }
155
+ };
156
+ currentPonyfill === null || currentPonyfill === void 0 ? void 0 : (_currentPonyfill_speechRecognition = currentPonyfill.speechRecognition) === null || _currentPonyfill_speechRecognition === void 0 ? void 0 : (_currentPonyfill_speechRecognition_abort = _currentPonyfill_speechRecognition.abort) === null || _currentPonyfill_speechRecognition_abort === void 0 ? void 0 : _currentPonyfill_speechRecognition_abort.call(_currentPonyfill_speechRecognition);
157
+ currentPonyfill = (0, $b6dTP$daviaiwebspeechcognitiveservicesdavi.createSpeechRecognitionPonyfill)(processedCredentials, options);
158
+ } else if (currentPonyfill) {
159
+ // Set wakeworkds
160
+ currentPonyfill.speechRecognition.wakeWords = getCommonAndLocalizedWakeWords(locale, agentData === null || agentData === void 0 ? void 0 : agentData.name);
161
+ // Set language
162
+ activeRecognitionState === (0, $kpW3P.RecognitionState).Listening ? currentPonyfill === null || currentPonyfill === void 0 ? void 0 : currentPonyfill.speechRecognition.changeLanguage(locale) : currentPonyfill.speechRecognition.lang = locale;
163
+ }
164
+ }
165
+ if (currentPonyfill) {
166
+ // Set grammar list
167
+ const grammarList = new (0, $b6dTP$daviaiwebspeechcognitiveservicesdavi.SpeechGrammarList)();
168
+ grammarList.phrases = getCommonAndLocalizedGrammars(locale);
169
+ if (speechRecognitionDynamicGrammars.length) speechRecognitionDynamicGrammars.forEach((grammar)=>{
170
+ !grammarList.phrases.includes(grammar) && grammarList.phrases.push(grammar);
171
+ });
172
+ if (agentData === null || agentData === void 0 ? void 0 : agentData.name) {
173
+ // Add raw name
174
+ !grammarList.phrases.includes(agentData.name) && grammarList.phrases.push(agentData.name);
175
+ // Add lower-cased name
176
+ !grammarList.phrases.includes(agentData.name.toLocaleLowerCase(locale)) && grammarList.phrases.push(agentData.name.toLocaleLowerCase(locale));
177
+ }
178
+ currentPonyfill.speechRecognition.grammars = grammarList;
179
+ setPonyfill(currentPonyfill);
180
+ }
181
+ }
182
+ }, [
183
+ ponyfillCredentials,
184
+ locale,
185
+ speechRecognitionDynamicGrammars,
186
+ agentData
187
+ ]);
188
+ /**
189
+ * Abort recognition if we are not on the 'home' page
190
+ */ (0, $b6dTP$react.useEffect)(()=>{
191
+ route !== (0, $kpW3P.Routes).Home && dispatch((0, $kpW3P.storeActions).speech.setActiveRecognitionState((0, $kpW3P.RecognitionState).Closed));
192
+ }, [
193
+ route
194
+ ]);
195
+ (0, $b6dTP$react.useEffect)(()=>{
196
+ if (ponyfill && appAvailable && loaderClosed) {
197
+ if (ponyfill.speechRecognition) {
198
+ ponyfill.speechRecognition.onstart = ()=>{
199
+ dispatch((0, $kpW3P.storeActions).speech.setActiveRecognitionState((0, $kpW3P.RecognitionState).Listening));
200
+ };
201
+ // onend callback is called only whithout using passive speech recognition
202
+ ponyfill.speechRecognition.onend = ()=>{
203
+ activeModeRef.current !== (0, $kpW3P.RecognitionState).Closed && dispatch((0, $kpW3P.storeActions).speech.setActiveRecognitionState((0, $kpW3P.RecognitionState).Closing));
204
+ };
205
+ ponyfill.speechRecognition.onabort = ()=>{
206
+ dispatch((0, $kpW3P.storeActions).speech.setActiveRecognitionState((0, $kpW3P.RecognitionState).Closed));
207
+ };
208
+ ponyfill.speechRecognition.onwakeup = ()=>{
209
+ if (activeModeRef.current === (0, $kpW3P.RecognitionState).Closed) {
210
+ console.log('Retorik Framework > wake word found, trying to open microphone');
211
+ activeModeRef.current === (0, $kpW3P.RecognitionState).Closed && dispatch((0, $kpW3P.storeActions).speech.toggleMicrophone(false));
212
+ } else console.log('Retorik Framework > wake word found, but microphone not ready');
213
+ };
214
+ ponyfill.speechRecognition.onresult = (result)=>{
215
+ const lastMessage = result.length ? result[result.length - 1].transcript : null;
216
+ // Only get result in Active mode
217
+ if (lastMessage && activeModeRef.current === (0, $kpW3P.RecognitionState).Listening) dispatch((0, $kpW3P.storeActions).speech.setLastRecognitionInterim(lastMessage));
218
+ };
219
+ setPonyfillReady(true);
220
+ }
221
+ }
222
+ }, [
223
+ ponyfill,
224
+ appAvailable,
225
+ loaderClosed
226
+ ]);
227
+ (0, $b6dTP$react.useEffect)(()=>{
228
+ if (ponyfillReady && mode === (0, $kpW3P.Mode).vocal) // Start passive recognition if not done yet
229
+ useContinuousRecognition && !(ponyfill === null || ponyfill === void 0 ? void 0 : ponyfill.speechRecognition.started) && askPermission();
230
+ }, [
231
+ mode,
232
+ ponyfillReady
233
+ ]);
234
+ const togglePassiveToActive = ()=>{
235
+ if (ponyfill === null || ponyfill === void 0 ? void 0 : ponyfill.speechRecognition.started) ponyfill.speechRecognition.toggleContinuousPassiveToActive();
236
+ else if (ponyfill) {
237
+ ponyfill.speechRecognition.passive = false;
238
+ ponyfill.speechRecognition.continuous = false;
239
+ ponyfill.speechRecognition.start();
240
+ }
241
+ };
242
+ (0, $b6dTP$react.useEffect)(()=>{
243
+ activeModeRef.current = activeRecognitionState;
244
+ if ((ponyfill === null || ponyfill === void 0 ? void 0 : ponyfill.speechRecognition) && appAvailable && loaderClosed) {
245
+ (timerRef === null || timerRef === void 0 ? void 0 : timerRef.current) && clearTimeout(timerRef.current);
246
+ switch(activeRecognitionState){
247
+ // Do nothing if we are in a transition state
248
+ case (0, $kpW3P.RecognitionState).Initializing:
249
+ useContinuousRecognition ? togglePassiveToActive() : ponyfill.speechRecognition.start();
250
+ break;
251
+ case (0, $kpW3P.RecognitionState).Listening:
252
+ break;
253
+ case (0, $kpW3P.RecognitionState).Closing:
254
+ if (lastRecognitionInterim) {
255
+ if (!delay) timerRef.current = setTimeout(()=>{
256
+ dispatch((0, $kpW3P.storeActions).directline.sendMessage({
257
+ text: lastRecognitionInterim
258
+ }));
259
+ dispatch((0, $kpW3P.storeActions).speech.setActiveRecognitionState((0, $kpW3P.RecognitionState).Closed));
260
+ }, $b0722e4118e770aa$var$timeoutDuration);
261
+ } else dispatch((0, $kpW3P.storeActions).speech.setActiveRecognitionState((0, $kpW3P.RecognitionState).Closed));
262
+ break;
263
+ case (0, $kpW3P.RecognitionState).ForceClosing:
264
+ var _ponyfill_speechRecognition_abort, _ponyfill_speechRecognition;
265
+ dispatch((0, $kpW3P.storeActions).speech.setLastRecognitionInterim(''));
266
+ // Let's abort the current recognition
267
+ ponyfill.speechRecognition.started ? (_ponyfill_speechRecognition_abort = (_ponyfill_speechRecognition = ponyfill.speechRecognition).abort) === null || _ponyfill_speechRecognition_abort === void 0 ? void 0 : _ponyfill_speechRecognition_abort.call(_ponyfill_speechRecognition) : dispatch((0, $kpW3P.storeActions).speech.setActiveRecognitionState((0, $kpW3P.RecognitionState).Closed));
268
+ break;
269
+ case (0, $kpW3P.RecognitionState).Closed:
270
+ if (useContinuousRecognition && mode === (0, $kpW3P.Mode).vocal) timerRef.current = setTimeout(()=>{
271
+ ponyfill.speechRecognition.toggleContinuousActiveToPassive();
272
+ }, $b0722e4118e770aa$var$timeoutDuration);
273
+ dispatch((0, $kpW3P.storeActions).speech.setLastRecognitionInterim(''));
274
+ break;
275
+ }
276
+ }
277
+ }, [
278
+ activeRecognitionState
279
+ ]);
280
+ return /*#__PURE__*/ (0, $b6dTP$reactjsxruntime.jsx)((0, ($parcel$interopDefault($b6dTP$react))).Fragment, {});
281
+ };
282
+ var $b0722e4118e770aa$export$2e2bcd8739ae039 = $b0722e4118e770aa$var$RecognitionManager;
283
+
284
+ });
285
+ parcelRegister("4vSkU", function(module, exports) {
286
+
287
+ $parcel$export(module.exports, "default", () => $d71a13f1dc50d60a$export$2e2bcd8739ae039);
288
+
289
+ var $kpW3P = parcelRequire("kpW3P");
290
+ const $d71a13f1dc50d60a$var$getMicrophonePermission = async ()=>{
291
+ try {
292
+ return navigator.mediaDevices.getUserMedia({
293
+ audio: true
294
+ }).then((stream)=>{
295
+ return stream ? (0, $kpW3P.PermissionStatus).allowed : (0, $kpW3P.PermissionStatus).refused;
296
+ }, (reason)=>{
297
+ console.log('Retorik Framework > microphone permission refused : ', reason);
298
+ return (0, $kpW3P.PermissionStatus).refused;
299
+ }).catch((error)=>{
300
+ console.log('Retorik Framework > microphone permission refused : ', error);
301
+ return (0, $kpW3P.PermissionStatus).error;
302
+ });
303
+ } catch (error) {
304
+ console.log('Retorik Framework > microphone permission refused : ', error);
305
+ return (0, $kpW3P.PermissionStatus).error;
306
+ }
307
+ };
308
+ var $d71a13f1dc50d60a$export$2e2bcd8739ae039 = $d71a13f1dc50d60a$var$getMicrophonePermission;
309
+
310
+ });
311
+
312
+
313
+
314
+ //# sourceMappingURL=RecognitionManager.cdfb39fc.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,MAAM,wCAAkB;AA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AAe,EAAE,OAAO,GAAG,CAAA,GAAA,uBAAe,EAAE,OAAO;QACrE,GACA,CAAC;YACC,QAAQ,GAAG,CACT,wDACA;YAEF,OAAO,CAAA,GAAA,uBAAe,EAAE,OAAO;QACjC,GAED,KAAK,CAAC,CAAC;YACN,QAAQ,GAAG,CACT,wDACA;YAEF,OAAO,CAAA,GAAA,uBAAe,EAAE,KAAK;QAC/B;IACJ,EAAE,OAAO,OAAO;QACd,QAAQ,GAAG,CAAC,wDAAwD;QACpE,OAAO,CAAA,GAAA,uBAAe,EAAE,KAAK;IAC/B;AACF;IAEA,2CAAe","sources":["src/components/Speech/RecognitionManager.tsx","src/utils/getMicrophonePermission.ts"],"sourcesContent":["import React, { useEffect, useRef, useState } from 'react'\r\nimport { createSpeechRecognitionPonyfill, SpeechGrammarList } from '@davi-ai/web-speech-cognitive-services-davi'\r\nimport type { PonyfillOptions, SpeechRecognitionPonyfillType, SpeechRecognitionProps, SpeechRecognitionResultList, SpeechRecognitionResultListItem } from '@davi-ai/web-speech-cognitive-services-davi'\r\nimport { useSelector, useDispatch } from 'react-redux'\r\nimport { RootState, storeActions, Mode, PermissionStatus, RecognitionState, Routes } from '../../store'\r\nimport getMicrophonePermission from '../../utils/getMicrophonePermission'\r\n\r\nconst timeoutDuration = 1000\r\n\r\nconst RecognitionManager = (): React.JSX.Element => {\r\n const dispatch = useDispatch()\r\n const locale = useSelector((state: RootState) => state.localeReducer.locale)\r\n const mode = useSelector((state: RootState) => state.speechReducer.mode)\r\n const appAvailable = useSelector((state: RootState) => state.retorikReducer.appAvailable)\r\n const loaderClosed = useSelector((state: RootState) => state.retorikReducer.loaderClosed)\r\n const agentData = useSelector((state: RootState) => state.retorikReducer.agentData)\r\n const delay = useSelector((state: RootState) => state.retorikReducer.submitDelayBeforeSendingMessage)\r\n const speechRecognitionOptions = useSelector((state: RootState) => state.retorikReducer.configuration.speechRecognitionOptions)\r\n const ponyfillCredentials = useSelector((state: RootState) => state.speechReducer.ponyfillCredentials)\r\n const useContinuousRecognition = useSelector((state: RootState) => state.speechReducer.useContinuousRecognition)\r\n const activeRecognitionState = useSelector((state: RootState) => state.speechReducer.activeRecognitionState)\r\n const lastRecognitionInterim = useSelector((state: RootState) => state.speechReducer.lastRecognitionInterim)\r\n const speechRecognitionDynamicGrammars = useSelector((state: RootState) => state.speechReducer.speechRecognitionDynamicGrammars)\r\n const route = useSelector((state: RootState) => state.viewReducer.route)\r\n\r\n const [ponyfill, setPonyfill] = useState<SpeechRecognitionPonyfillType | null>(null)\r\n const [recognitionAllowed, setRecognitionAllowed] = useState<boolean>(false)\r\n const [ponyfillReady, setPonyfillReady] = useState<boolean>(false)\r\n\r\n const activeModeRef = useRef<RecognitionState | undefined>(undefined)\r\n const timerRef = useRef<NodeJS.Timeout | null>(null)\r\n const localeRef = useRef<string | undefined>(undefined)\r\n\r\n const getCommonAndLocalizedWakeWords = (currentLocale: string, agentName?: string): Array<string> => {\r\n let commonAndlocalizedWakeWords: Array<string> = []\r\n if (speechRecognitionOptions?.wakeWords) {\r\n if (speechRecognitionOptions.wakeWords.common) {\r\n commonAndlocalizedWakeWords = [...speechRecognitionOptions.wakeWords.common]\r\n }\r\n\r\n if (speechRecognitionOptions.wakeWords.localized) {\r\n const localizedWakeWords = speechRecognitionOptions.wakeWords.localized[currentLocale] || []\r\n localizedWakeWords.length && (commonAndlocalizedWakeWords = [...commonAndlocalizedWakeWords, ...localizedWakeWords])\r\n }\r\n }\r\n\r\n // Add agent's name to wake words\r\n agentName && (commonAndlocalizedWakeWords = [...commonAndlocalizedWakeWords, agentName])\r\n\r\n return commonAndlocalizedWakeWords\r\n }\r\n\r\n const getCommonAndLocalizedGrammars = (currentLocale: string): Array<string> => {\r\n let commonAndlocalizedGrammars: Array<string> = []\r\n if (speechRecognitionOptions?.grammars) {\r\n if (speechRecognitionOptions.grammars.common) {\r\n commonAndlocalizedGrammars = [...speechRecognitionOptions.grammars.common]\r\n }\r\n\r\n if (speechRecognitionOptions.grammars.localized) {\r\n const localizedGrammars = speechRecognitionOptions.grammars.localized[currentLocale] || []\r\n localizedGrammars.length && (commonAndlocalizedGrammars = [...commonAndlocalizedGrammars, ...localizedGrammars])\r\n }\r\n }\r\n\r\n return commonAndlocalizedGrammars\r\n }\r\n\r\n const askPermission = (): void => {\r\n if (recognitionAllowed) {\r\n ponyfill?.speechRecognition.start()\r\n } else {\r\n getMicrophonePermission()\r\n .then((permission) => {\r\n setRecognitionAllowed(permission === PermissionStatus.allowed)\r\n })\r\n .catch(console.log)\r\n }\r\n }\r\n\r\n useEffect(() => {\r\n // Clear data on component unmount\r\n return () => {\r\n timerRef?.current && clearTimeout(timerRef.current)\r\n ponyfill?.speechRecognition?.abort?.()\r\n }\r\n }, [])\r\n\r\n useEffect(() => {\r\n recognitionAllowed && useContinuousRecognition && ponyfill?.speechRecognition.start()\r\n }, [recognitionAllowed])\r\n\r\n useEffect(() => {\r\n if (ponyfillCredentials && locale && agentData) {\r\n let currentPonyfill = ponyfill\r\n if (locale !== localeRef.current) {\r\n localeRef.current = locale\r\n // We create the ponyfill if it isn't created yet. We recreate a new one if we are using custom endpoints for speech recognition.\r\n if (!ponyfill || ponyfillCredentials?.speechRecognitionHostnamesRecord) {\r\n // Check if we need to use a custom endpoint from speechRecognitionHostnamesRecord\r\n const speechRecognitionHostname = ponyfillCredentials?.speechRecognitionHostnamesRecord\r\n ? ponyfillCredentials.speechRecognitionHostnamesRecord[locale] || Object.values(ponyfillCredentials.speechRecognitionHostnamesRecord)[0]\r\n : undefined\r\n\r\n const options: SpeechRecognitionProps = {\r\n autoStart: false,\r\n continuous: useContinuousRecognition,\r\n interimResults: true,\r\n grammarsList: getCommonAndLocalizedGrammars(locale),\r\n lang: locale,\r\n passive: useContinuousRecognition,\r\n wakeWords: getCommonAndLocalizedWakeWords(locale),\r\n debug: false,\r\n timerBeforeSpeechEnd: speechRecognitionOptions?.timerBeforeSpeechEnd\r\n }\r\n\r\n const processedCredentials: PonyfillOptions = {\r\n credentials: speechRecognitionHostname\r\n ? {\r\n region: undefined,\r\n subscriptionKey: ponyfillCredentials.subscriptionKey || 'mandatory_subscription_key',\r\n speechRecognitionHostname: speechRecognitionHostname,\r\n speechSynthesisHostname: 'mandatory_synthesis_host_name'\r\n }\r\n : {\r\n region: ponyfillCredentials.region,\r\n subscriptionKey: ponyfillCredentials.subscriptionKey,\r\n authorizationToken: ponyfillCredentials.authorizationToken\r\n }\r\n }\r\n\r\n // Abort current recognition before setting the new recognition ponyfill if there is a need to\r\n currentPonyfill?.speechRecognition?.abort?.()\r\n currentPonyfill = createSpeechRecognitionPonyfill(processedCredentials, options)\r\n } else if (currentPonyfill) {\r\n // Set wakeworkds\r\n currentPonyfill.speechRecognition.wakeWords = getCommonAndLocalizedWakeWords(locale, agentData?.name)\r\n // Set language\r\n activeRecognitionState === RecognitionState.Listening ? currentPonyfill?.speechRecognition.changeLanguage(locale) : (currentPonyfill.speechRecognition.lang = locale)\r\n }\r\n }\r\n\r\n if (currentPonyfill) {\r\n // Set grammar list\r\n const grammarList = new SpeechGrammarList()\r\n grammarList.phrases = getCommonAndLocalizedGrammars(locale)\r\n if (speechRecognitionDynamicGrammars.length) {\r\n speechRecognitionDynamicGrammars.forEach((grammar) => {\r\n !grammarList.phrases.includes(grammar) && grammarList.phrases.push(grammar)\r\n })\r\n }\r\n\r\n if (agentData?.name) {\r\n // Add raw name\r\n !grammarList.phrases.includes(agentData.name) && grammarList.phrases.push(agentData.name)\r\n // Add lower-cased name\r\n !grammarList.phrases.includes(agentData.name.toLocaleLowerCase(locale)) && grammarList.phrases.push(agentData.name.toLocaleLowerCase(locale))\r\n }\r\n currentPonyfill.speechRecognition.grammars = grammarList\r\n\r\n setPonyfill(currentPonyfill)\r\n }\r\n }\r\n }, [ponyfillCredentials, locale, speechRecognitionDynamicGrammars, agentData])\r\n\r\n /**\r\n * Abort recognition if we are not on the 'home' page\r\n */\r\n useEffect(() => {\r\n route !== Routes.Home && dispatch(storeActions.speech.setActiveRecognitionState(RecognitionState.Closed))\r\n }, [route])\r\n\r\n useEffect(() => {\r\n if (ponyfill && appAvailable && loaderClosed) {\r\n if (ponyfill.speechRecognition) {\r\n ponyfill.speechRecognition.onstart = () => {\r\n dispatch(storeActions.speech.setActiveRecognitionState(RecognitionState.Listening))\r\n }\r\n\r\n // onend callback is called only whithout using passive speech recognition\r\n ponyfill.speechRecognition.onend = () => {\r\n activeModeRef.current !== RecognitionState.Closed && dispatch(storeActions.speech.setActiveRecognitionState(RecognitionState.Closing))\r\n }\r\n\r\n ponyfill.speechRecognition.onabort = () => {\r\n dispatch(storeActions.speech.setActiveRecognitionState(RecognitionState.Closed))\r\n }\r\n\r\n ponyfill.speechRecognition.onwakeup = () => {\r\n if (activeModeRef.current === RecognitionState.Closed) {\r\n console.log('Retorik Framework > wake word found, trying to open microphone')\r\n activeModeRef.current === RecognitionState.Closed && dispatch(storeActions.speech.toggleMicrophone(false))\r\n } else {\r\n console.log('Retorik Framework > wake word found, but microphone not ready')\r\n }\r\n }\r\n\r\n ponyfill.speechRecognition.onresult = (result: SpeechRecognitionResultList | Array<SpeechRecognitionResultListItem>) => {\r\n const lastMessage: string | null = result.length ? result[result.length - 1].transcript : null\r\n // Only get result in Active mode\r\n if (lastMessage && activeModeRef.current === RecognitionState.Listening) {\r\n dispatch(storeActions.speech.setLastRecognitionInterim(lastMessage))\r\n }\r\n }\r\n\r\n setPonyfillReady(true)\r\n }\r\n }\r\n }, [ponyfill, appAvailable, loaderClosed])\r\n\r\n useEffect(() => {\r\n if (ponyfillReady && mode === Mode.vocal) {\r\n // Start passive recognition if not done yet\r\n useContinuousRecognition && !ponyfill?.speechRecognition.started && askPermission()\r\n }\r\n }, [mode, ponyfillReady])\r\n\r\n const togglePassiveToActive = (): void => {\r\n if (ponyfill?.speechRecognition.started) {\r\n ponyfill.speechRecognition.toggleContinuousPassiveToActive()\r\n } else {\r\n if (ponyfill) {\r\n ponyfill.speechRecognition.passive = false\r\n ponyfill.speechRecognition.continuous = false\r\n ponyfill.speechRecognition.start()\r\n }\r\n }\r\n }\r\n\r\n useEffect(() => {\r\n activeModeRef.current = activeRecognitionState\r\n\r\n if (ponyfill?.speechRecognition && appAvailable && loaderClosed) {\r\n timerRef?.current && clearTimeout(timerRef.current)\r\n switch (activeRecognitionState) {\r\n // Do nothing if we are in a transition state\r\n case RecognitionState.Initializing: {\r\n useContinuousRecognition ? togglePassiveToActive() : ponyfill.speechRecognition.start()\r\n break\r\n }\r\n case RecognitionState.Listening:\r\n break\r\n case RecognitionState.Closing: {\r\n if (lastRecognitionInterim) {\r\n if (!delay) {\r\n timerRef.current = setTimeout(() => {\r\n dispatch(storeActions.directline.sendMessage({ text: lastRecognitionInterim }))\r\n\r\n dispatch(storeActions.speech.setActiveRecognitionState(RecognitionState.Closed))\r\n }, timeoutDuration)\r\n }\r\n } else {\r\n dispatch(storeActions.speech.setActiveRecognitionState(RecognitionState.Closed))\r\n }\r\n break\r\n }\r\n case RecognitionState.ForceClosing: {\r\n dispatch(storeActions.speech.setLastRecognitionInterim(''))\r\n\r\n // Let's abort the current recognition\r\n ponyfill.speechRecognition.started ? ponyfill.speechRecognition.abort?.() : dispatch(storeActions.speech.setActiveRecognitionState(RecognitionState.Closed))\r\n break\r\n }\r\n case RecognitionState.Closed: {\r\n if (useContinuousRecognition && mode === Mode.vocal) {\r\n timerRef.current = setTimeout(() => {\r\n ponyfill.speechRecognition.toggleContinuousActiveToPassive()\r\n }, timeoutDuration)\r\n }\r\n dispatch(storeActions.speech.setLastRecognitionInterim(''))\r\n break\r\n }\r\n }\r\n }\r\n }, [activeRecognitionState])\r\n\r\n return <React.Fragment />\r\n}\r\n\r\nexport default RecognitionManager\r\n","import { PermissionStatus } from '../store'\r\n\r\nconst getMicrophonePermission = async (): Promise<PermissionStatus> => {\r\n try {\r\n return navigator.mediaDevices\r\n .getUserMedia({ audio: true })\r\n .then(\r\n (stream) => {\r\n return stream ? PermissionStatus.allowed : PermissionStatus.refused\r\n },\r\n (reason) => {\r\n console.log(\r\n 'Retorik Framework > microphone permission refused : ',\r\n reason\r\n )\r\n return PermissionStatus.refused\r\n }\r\n )\r\n .catch((error) => {\r\n console.log(\r\n 'Retorik Framework > microphone permission refused : ',\r\n error\r\n )\r\n return PermissionStatus.error\r\n })\r\n } catch (error) {\r\n console.log('Retorik Framework > microphone permission refused : ', error)\r\n return PermissionStatus.error\r\n }\r\n}\r\n\r\nexport default getMicrophonePermission\r\n"],"names":[],"version":3,"file":"RecognitionManager.cdfb39fc.js.map","sourceRoot":"../"}
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBA,MAAM,4CAAsB,CAAC,aAAE,SAAS,cAAE,UAAU,UAAE,MAAM,QAAE,IAAI,EAA4B;IAC5F,MAAM,WAAW,CAAA,GAAA,kBAAU;IAC3B,MAAM,qBAAqB,CAAA,GAAA,cAAgB;IAC3C,MAAM,CAAC,gBAAgB,kBAAkB,GAAG,CAAA,GAAA,eAAO,EAAiB,EAAE;IAEtE,CAAA,GAAA,gBAAQ,EAAE;QACR,gFAAgF;QAChF,SAAS,CAAA,GAAA,mBAAW,EAAE,IAAI,CAAC,kBAAkB,CAAC;IAChD,GAAG,EAAE;IAEL,CAAA,GAAA,gBAAQ,EAAE;QACR,sBAAsB,kBAAkB;IAC1C,GAAG;QAAC;KAAmB;IAEvB,qBAAO,gBAAC,CAAA,GAAA,6BAAc;QAAE,SAAQ;QAAU,WAAW;QAAW,QAAQ;QAAQ,MAAM;QAAM,OAAO;QAAY,gBAAgB;QAAgB,mBAAmB;;AACpK;IAEA,2CAAe;;;;;;;;AC5BA;IACb,MAAM,kBAA+C,CAAA,GAAA,kBAAU,EAAE,CAAC,QAAqB,MAAM,eAAe,CAAC,eAAe;IAC5H,MAAM,CAAC,gBAAgB,kBAAkB,GAAG,CAAA,GAAA,eAAO;IAEnD,MAAM,cAAc,CAAC;QACnB,EAAE,MAAM,IAAI,kBAAkB,EAAE,MAAM,CAAC,KAAK;IAC9C;IAEA,CAAA,GAAA,gBAAQ,EAAE;QACR,SAAS,gBAAgB,CAAC,0BAA2B,CAAC,QAAuB,YAAY;IAC3F,GAAG,EAAE;IAEL,CAAA,GAAA,gBAAQ,EAAE;QACR,iBAAiB,MAAM,OAAO,UAAU,kBAAkB,gBAAgB,IAAI,CAAC,KAAK;IACtF,GAAG;QAAC;KAAgB;IAEpB,OAAO;AACT","sources":["src/components/ChatbotAndSubtitles/SpiritEngineWrapper.tsx","src/hooks/useAnimationQueue.ts"],"sourcesContent":["import React, { useEffect, useState } from 'react'\r\nimport ChatbotProvider from '@davi-ai/body-engine-sprite'\r\nimport { useDispatch } from 'react-redux'\r\nimport { storeActions } from '../../store'\r\nimport useAnimationQueue from '../../hooks/useAnimationQueue'\r\nimport { AgentData } from '../../models/types'\r\n\r\ntype SpiritEngineWrapperAgentData = Exclude<AgentData, null>\r\n\r\ninterface SpiritEngineWrapperProps {\r\n agentData: SpiritEngineWrapperAgentData\r\n isSpeaking: boolean\r\n height?: number | string\r\n size?: number | string\r\n}\r\n\r\nconst SpiritEngineWrapper = ({ agentData, isSpeaking, height, size }: SpiritEngineWrapperProps): JSX.Element => {\r\n const dispatch = useDispatch()\r\n const lastAnimationQueue = useAnimationQueue()\r\n const [animationQueue, setAnimationQueue] = useState<Array<string>>([])\r\n\r\n useEffect(() => {\r\n // With spirit engine, set the character as loaded once the component is mounted\r\n dispatch(storeActions.view.setCharacterLoaded(true))\r\n }, [])\r\n\r\n useEffect(() => {\r\n lastAnimationQueue && setAnimationQueue(lastAnimationQueue)\r\n }, [lastAnimationQueue])\r\n\r\n return <ChatbotProvider licence='licence' agentData={agentData} height={height} size={size} speak={isSpeaking} animationQueue={animationQueue} setAnimationQueue={setAnimationQueue} />\r\n}\r\n\r\nexport default SpiritEngineWrapper\r\n","import { useEffect, useState } from 'react'\r\nimport { useSelector } from 'react-redux'\r\nimport { RootState } from '../store'\r\nimport type { RetorikActivity } from '../models/activityTypes'\r\n\r\nexport default function useAnimationQueue(): Array<string> | undefined {\r\n const lastBotActivity: RetorikActivity | undefined = useSelector((state: RootState) => state.activityReducer.lastBotActivity)\r\n const [animationQueue, setAnimationQueue] = useState<Array<string>>()\r\n\r\n const handleEvent = (e: CustomEvent): void => {\r\n e.detail && setAnimationQueue(e.detail.queue)\r\n }\r\n\r\n useEffect(() => {\r\n document.addEventListener('sendPlayAnimationEvent', ((event: CustomEvent) => handleEvent(event)) as EventListener)\r\n }, [])\r\n\r\n useEffect(() => {\r\n lastBotActivity?.meta?.queue?.length && setAnimationQueue(lastBotActivity.meta.queue)\r\n }, [lastBotActivity])\r\n\r\n return animationQueue\r\n}\r\n"],"names":[],"version":3,"file":"SpiritEngineWrapper.21ea10d4.js.map"}
1
+ {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBA,MAAM,4CAAsB,CAAC,aAAE,SAAS,cAAE,UAAU,UAAE,MAAM,QAAE,IAAI,EAA4B;IAC5F,MAAM,WAAW,CAAA,GAAA,kBAAU;IAC3B,MAAM,qBAAqB,CAAA,GAAA,cAAgB;IAC3C,MAAM,CAAC,gBAAgB,kBAAkB,GAAG,CAAA,GAAA,eAAO,EAAiB,EAAE;IAEtE,CAAA,GAAA,gBAAQ,EAAE;QACR,gFAAgF;QAChF,SAAS,CAAA,GAAA,mBAAW,EAAE,IAAI,CAAC,kBAAkB,CAAC;IAChD,GAAG,EAAE;IAEL,CAAA,GAAA,gBAAQ,EAAE;QACR,sBAAsB,kBAAkB;IAC1C,GAAG;QAAC;KAAmB;IAEvB,qBAAO,gBAAC,CAAA,GAAA,6BAAc;QAAE,SAAQ;QAAU,WAAW;QAAW,QAAQ;QAAQ,MAAM;QAAM,OAAO;QAAY,gBAAgB;QAAgB,mBAAmB;;AACpK;IAEA,2CAAe;;;;;;;;AC5BA;IACb,MAAM,kBAA+C,CAAA,GAAA,kBAAU,EAAE,CAAC,QAAqB,MAAM,eAAe,CAAC,eAAe;IAC5H,MAAM,CAAC,gBAAgB,kBAAkB,GAAG,CAAA,GAAA,eAAO;IAEnD,MAAM,cAAc,CAAC;QACnB,EAAE,MAAM,IAAI,kBAAkB,EAAE,MAAM,CAAC,KAAK;IAC9C;IAEA,CAAA,GAAA,gBAAQ,EAAE;QACR,SAAS,gBAAgB,CAAC,0BAA2B,CAAC,QAAuB,YAAY;IAC3F,GAAG,EAAE;IAEL,CAAA,GAAA,gBAAQ,EAAE;QACR,iBAAiB,MAAM,OAAO,UAAU,kBAAkB,gBAAgB,IAAI,CAAC,KAAK;IACtF,GAAG;QAAC;KAAgB;IAEpB,OAAO;AACT","sources":["src/components/ChatbotAndSubtitles/SpiritEngineWrapper.tsx","src/hooks/useAnimationQueue.ts"],"sourcesContent":["import React, { useEffect, useState } from 'react'\r\nimport ChatbotProvider from '@davi-ai/body-engine-sprite'\r\nimport { useDispatch } from 'react-redux'\r\nimport { storeActions } from '../../store'\r\nimport useAnimationQueue from '../../hooks/useAnimationQueue'\r\nimport { AgentData } from '../../store/models/types'\r\n\r\ntype SpiritEngineWrapperAgentData = Exclude<AgentData, null>\r\n\r\ninterface SpiritEngineWrapperProps {\r\n agentData: SpiritEngineWrapperAgentData\r\n isSpeaking: boolean\r\n height?: number | string\r\n size?: number | string\r\n}\r\n\r\nconst SpiritEngineWrapper = ({ agentData, isSpeaking, height, size }: SpiritEngineWrapperProps): React.JSX.Element => {\r\n const dispatch = useDispatch()\r\n const lastAnimationQueue = useAnimationQueue()\r\n const [animationQueue, setAnimationQueue] = useState<Array<string>>([])\r\n\r\n useEffect(() => {\r\n // With spirit engine, set the character as loaded once the component is mounted\r\n dispatch(storeActions.view.setCharacterLoaded(true))\r\n }, [])\r\n\r\n useEffect(() => {\r\n lastAnimationQueue && setAnimationQueue(lastAnimationQueue)\r\n }, [lastAnimationQueue])\r\n\r\n return <ChatbotProvider licence='licence' agentData={agentData} height={height} size={size} speak={isSpeaking} animationQueue={animationQueue} setAnimationQueue={setAnimationQueue} />\r\n}\r\n\r\nexport default SpiritEngineWrapper\r\n","import { useEffect, useState } from 'react'\r\nimport { useSelector } from 'react-redux'\r\nimport { RootState } from '../store'\r\nimport type { RetorikActivity } from '../store/models/activityTypes'\r\n\r\nexport default function useAnimationQueue(): Array<string> | undefined {\r\n const lastBotActivity: RetorikActivity | undefined = useSelector((state: RootState) => state.activityReducer.lastBotActivity)\r\n const [animationQueue, setAnimationQueue] = useState<Array<string>>()\r\n\r\n const handleEvent = (e: CustomEvent): void => {\r\n e.detail && setAnimationQueue(e.detail.queue)\r\n }\r\n\r\n useEffect(() => {\r\n document.addEventListener('sendPlayAnimationEvent', ((event: CustomEvent) => handleEvent(event)) as EventListener)\r\n }, [])\r\n\r\n useEffect(() => {\r\n lastBotActivity?.meta?.queue?.length && setAnimationQueue(lastBotActivity.meta.queue)\r\n }, [lastBotActivity])\r\n\r\n return animationQueue\r\n}\r\n"],"names":[],"version":3,"file":"SpiritEngineWrapper.21ea10d4.js.map"}
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBA,MAAM,4CAAsB,CAAC,aAAE,SAAS,cAAE,UAAU,UAAE,MAAM,QAAE,IAAI,EAA4B;IAC5F,MAAM,WAAW,CAAA,GAAA,6BAAU;IAC3B,MAAM,qBAAqB,CAAA,GAAA,cAAgB;IAC3C,MAAM,CAAC,gBAAgB,kBAAkB,GAAG,CAAA,GAAA,qBAAO,EAAiB,EAAE;IAEtE,CAAA,GAAA,sBAAQ,EAAE;QACR,gFAAgF;QAChF,SAAS,CAAA,GAAA,mBAAW,EAAE,IAAI,CAAC,kBAAkB,CAAC;IAChD,GAAG,EAAE;IAEL,CAAA,GAAA,sBAAQ,EAAE;QACR,sBAAsB,kBAAkB;IAC1C,GAAG;QAAC;KAAmB;IAEvB,qBAAO,gCAAC,CAAA,GAAA,uDAAc;QAAE,SAAQ;QAAU,WAAW;QAAW,QAAQ;QAAQ,MAAM;QAAM,OAAO;QAAY,gBAAgB;QAAgB,mBAAmB;;AACpK;IAEA,2CAAe;;;;;;;;AC5BA;IACb,MAAM,kBAA+C,CAAA,GAAA,6BAAU,EAAE,CAAC,QAAqB,MAAM,eAAe,CAAC,eAAe;IAC5H,MAAM,CAAC,gBAAgB,kBAAkB,GAAG,CAAA,GAAA,qBAAO;IAEnD,MAAM,cAAc,CAAC;QACnB,EAAE,MAAM,IAAI,kBAAkB,EAAE,MAAM,CAAC,KAAK;IAC9C;IAEA,CAAA,GAAA,sBAAQ,EAAE;QACR,SAAS,gBAAgB,CAAC,0BAA2B,CAAC,QAAuB,YAAY;IAC3F,GAAG,EAAE;IAEL,CAAA,GAAA,sBAAQ,EAAE;YACR,6BAAA;QAAA,CAAA,4BAAA,uCAAA,wBAAA,gBAAiB,IAAI,cAArB,6CAAA,8BAAA,sBAAuB,KAAK,cAA5B,kDAAA,4BAA8B,MAAM,KAAI,kBAAkB,gBAAgB,IAAI,CAAC,KAAK;IACtF,GAAG;QAAC;KAAgB;IAEpB,OAAO;AACT","sources":["src/components/ChatbotAndSubtitles/SpiritEngineWrapper.tsx","src/hooks/useAnimationQueue.ts"],"sourcesContent":["import React, { useEffect, useState } from 'react'\r\nimport ChatbotProvider from '@davi-ai/body-engine-sprite'\r\nimport { useDispatch } from 'react-redux'\r\nimport { storeActions } from '../../store'\r\nimport useAnimationQueue from '../../hooks/useAnimationQueue'\r\nimport { AgentData } from '../../models/types'\r\n\r\ntype SpiritEngineWrapperAgentData = Exclude<AgentData, null>\r\n\r\ninterface SpiritEngineWrapperProps {\r\n agentData: SpiritEngineWrapperAgentData\r\n isSpeaking: boolean\r\n height?: number | string\r\n size?: number | string\r\n}\r\n\r\nconst SpiritEngineWrapper = ({ agentData, isSpeaking, height, size }: SpiritEngineWrapperProps): JSX.Element => {\r\n const dispatch = useDispatch()\r\n const lastAnimationQueue = useAnimationQueue()\r\n const [animationQueue, setAnimationQueue] = useState<Array<string>>([])\r\n\r\n useEffect(() => {\r\n // With spirit engine, set the character as loaded once the component is mounted\r\n dispatch(storeActions.view.setCharacterLoaded(true))\r\n }, [])\r\n\r\n useEffect(() => {\r\n lastAnimationQueue && setAnimationQueue(lastAnimationQueue)\r\n }, [lastAnimationQueue])\r\n\r\n return <ChatbotProvider licence='licence' agentData={agentData} height={height} size={size} speak={isSpeaking} animationQueue={animationQueue} setAnimationQueue={setAnimationQueue} />\r\n}\r\n\r\nexport default SpiritEngineWrapper\r\n","import { useEffect, useState } from 'react'\r\nimport { useSelector } from 'react-redux'\r\nimport { RootState } from '../store'\r\nimport type { RetorikActivity } from '../models/activityTypes'\r\n\r\nexport default function useAnimationQueue(): Array<string> | undefined {\r\n const lastBotActivity: RetorikActivity | undefined = useSelector((state: RootState) => state.activityReducer.lastBotActivity)\r\n const [animationQueue, setAnimationQueue] = useState<Array<string>>()\r\n\r\n const handleEvent = (e: CustomEvent): void => {\r\n e.detail && setAnimationQueue(e.detail.queue)\r\n }\r\n\r\n useEffect(() => {\r\n document.addEventListener('sendPlayAnimationEvent', ((event: CustomEvent) => handleEvent(event)) as EventListener)\r\n }, [])\r\n\r\n useEffect(() => {\r\n lastBotActivity?.meta?.queue?.length && setAnimationQueue(lastBotActivity.meta.queue)\r\n }, [lastBotActivity])\r\n\r\n return animationQueue\r\n}\r\n"],"names":[],"version":3,"file":"SpiritEngineWrapper.39627300.js.map","sourceRoot":"../"}
1
+ {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBA,MAAM,4CAAsB,CAAC,aAAE,SAAS,cAAE,UAAU,UAAE,MAAM,QAAE,IAAI,EAA4B;IAC5F,MAAM,WAAW,CAAA,GAAA,6BAAU;IAC3B,MAAM,qBAAqB,CAAA,GAAA,cAAgB;IAC3C,MAAM,CAAC,gBAAgB,kBAAkB,GAAG,CAAA,GAAA,qBAAO,EAAiB,EAAE;IAEtE,CAAA,GAAA,sBAAQ,EAAE;QACR,gFAAgF;QAChF,SAAS,CAAA,GAAA,mBAAW,EAAE,IAAI,CAAC,kBAAkB,CAAC;IAChD,GAAG,EAAE;IAEL,CAAA,GAAA,sBAAQ,EAAE;QACR,sBAAsB,kBAAkB;IAC1C,GAAG;QAAC;KAAmB;IAEvB,qBAAO,gCAAC,CAAA,GAAA,uDAAc;QAAE,SAAQ;QAAU,WAAW;QAAW,QAAQ;QAAQ,MAAM;QAAM,OAAO;QAAY,gBAAgB;QAAgB,mBAAmB;;AACpK;IAEA,2CAAe;;;;;;;;AC5BA;IACb,MAAM,kBAA+C,CAAA,GAAA,6BAAU,EAAE,CAAC,QAAqB,MAAM,eAAe,CAAC,eAAe;IAC5H,MAAM,CAAC,gBAAgB,kBAAkB,GAAG,CAAA,GAAA,qBAAO;IAEnD,MAAM,cAAc,CAAC;QACnB,EAAE,MAAM,IAAI,kBAAkB,EAAE,MAAM,CAAC,KAAK;IAC9C;IAEA,CAAA,GAAA,sBAAQ,EAAE;QACR,SAAS,gBAAgB,CAAC,0BAA2B,CAAC,QAAuB,YAAY;IAC3F,GAAG,EAAE;IAEL,CAAA,GAAA,sBAAQ,EAAE;YACR,6BAAA;QAAA,CAAA,4BAAA,uCAAA,wBAAA,gBAAiB,IAAI,cAArB,6CAAA,8BAAA,sBAAuB,KAAK,cAA5B,kDAAA,4BAA8B,MAAM,KAAI,kBAAkB,gBAAgB,IAAI,CAAC,KAAK;IACtF,GAAG;QAAC;KAAgB;IAEpB,OAAO;AACT","sources":["src/components/ChatbotAndSubtitles/SpiritEngineWrapper.tsx","src/hooks/useAnimationQueue.ts"],"sourcesContent":["import React, { useEffect, useState } from 'react'\r\nimport ChatbotProvider from '@davi-ai/body-engine-sprite'\r\nimport { useDispatch } from 'react-redux'\r\nimport { storeActions } from '../../store'\r\nimport useAnimationQueue from '../../hooks/useAnimationQueue'\r\nimport { AgentData } from '../../store/models/types'\r\n\r\ntype SpiritEngineWrapperAgentData = Exclude<AgentData, null>\r\n\r\ninterface SpiritEngineWrapperProps {\r\n agentData: SpiritEngineWrapperAgentData\r\n isSpeaking: boolean\r\n height?: number | string\r\n size?: number | string\r\n}\r\n\r\nconst SpiritEngineWrapper = ({ agentData, isSpeaking, height, size }: SpiritEngineWrapperProps): React.JSX.Element => {\r\n const dispatch = useDispatch()\r\n const lastAnimationQueue = useAnimationQueue()\r\n const [animationQueue, setAnimationQueue] = useState<Array<string>>([])\r\n\r\n useEffect(() => {\r\n // With spirit engine, set the character as loaded once the component is mounted\r\n dispatch(storeActions.view.setCharacterLoaded(true))\r\n }, [])\r\n\r\n useEffect(() => {\r\n lastAnimationQueue && setAnimationQueue(lastAnimationQueue)\r\n }, [lastAnimationQueue])\r\n\r\n return <ChatbotProvider licence='licence' agentData={agentData} height={height} size={size} speak={isSpeaking} animationQueue={animationQueue} setAnimationQueue={setAnimationQueue} />\r\n}\r\n\r\nexport default SpiritEngineWrapper\r\n","import { useEffect, useState } from 'react'\r\nimport { useSelector } from 'react-redux'\r\nimport { RootState } from '../store'\r\nimport type { RetorikActivity } from '../store/models/activityTypes'\r\n\r\nexport default function useAnimationQueue(): Array<string> | undefined {\r\n const lastBotActivity: RetorikActivity | undefined = useSelector((state: RootState) => state.activityReducer.lastBotActivity)\r\n const [animationQueue, setAnimationQueue] = useState<Array<string>>()\r\n\r\n const handleEvent = (e: CustomEvent): void => {\r\n e.detail && setAnimationQueue(e.detail.queue)\r\n }\r\n\r\n useEffect(() => {\r\n document.addEventListener('sendPlayAnimationEvent', ((event: CustomEvent) => handleEvent(event)) as EventListener)\r\n }, [])\r\n\r\n useEffect(() => {\r\n lastBotActivity?.meta?.queue?.length && setAnimationQueue(lastBotActivity.meta.queue)\r\n }, [lastBotActivity])\r\n\r\n return animationQueue\r\n}\r\n"],"names":[],"version":3,"file":"SpiritEngineWrapper.39627300.js.map","sourceRoot":"../"}