@davi-ai/retorik-framework 3.2.3 → 3.2.4
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/dist/{AttachmentDetail.1e06c2a5.js → AttachmentDetail.cfd86776.js} +2 -3
- package/dist/AttachmentDetail.cfd86776.js.map +1 -0
- package/dist/{AttachmentDetail.c6c297df.js → AttachmentDetail.fdcd1737.js} +2 -3
- package/dist/AttachmentDetail.fdcd1737.js.map +1 -0
- package/dist/{CustomView.080c8028.js → CustomView.ba7af9b6.js} +2 -3
- package/dist/CustomView.ba7af9b6.js.map +1 -0
- package/dist/{CustomView.90d2a13d.js → CustomView.c24a0e74.js} +2 -3
- package/dist/CustomView.c24a0e74.js.map +1 -0
- package/dist/{Emergency.a21f837c.js → Emergency.0cf005ce.js} +2 -3
- package/dist/Emergency.0cf005ce.js.map +1 -0
- package/dist/{Emergency.423214ad.js → Emergency.897ee3c7.js} +2 -3
- package/dist/Emergency.897ee3c7.js.map +1 -0
- package/dist/{HistoryList.5fd6aa12.js → HistoryList.03a56119.js} +3 -7
- package/dist/HistoryList.03a56119.js.map +1 -0
- package/dist/{HistoryList.50ff0fd9.js → HistoryList.4c303dc6.js} +3 -7
- package/dist/HistoryList.4c303dc6.js.map +1 -0
- package/dist/{LanguageChoice.61e36c1d.js → LanguageChoice.623ee802.js} +2 -5
- package/dist/LanguageChoice.623ee802.js.map +1 -0
- package/dist/{LanguageChoice.1579b654.js → LanguageChoice.ff0cd04c.js} +2 -5
- package/dist/LanguageChoice.ff0cd04c.js.map +1 -0
- package/dist/{NewsContainer.67f04b19.js → NewsContainer.05bb1b19.js} +9 -9
- package/dist/NewsContainer.05bb1b19.js.map +1 -0
- package/dist/{NewsContainer.932174e9.js → NewsContainer.5e80336b.js} +9 -9
- package/dist/NewsContainer.5e80336b.js.map +1 -0
- package/dist/{Weather.661c2cac.js → Weather.99917b66.js} +2 -3
- package/dist/Weather.99917b66.js.map +1 -0
- package/dist/{Weather.fb22fba3.js → Weather.cf58823d.js} +2 -3
- package/dist/Weather.cf58823d.js.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +323 -544
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +309 -537
- package/dist/index.modern.js.map +1 -1
- package/package.json +1 -1
- package/dist/AttachmentDetail.1e06c2a5.js.map +0 -1
- package/dist/AttachmentDetail.c6c297df.js.map +0 -1
- package/dist/CustomView.080c8028.js.map +0 -1
- package/dist/CustomView.90d2a13d.js.map +0 -1
- package/dist/Emergency.423214ad.js.map +0 -1
- package/dist/Emergency.a21f837c.js.map +0 -1
- package/dist/HistoryList.50ff0fd9.js.map +0 -1
- package/dist/HistoryList.5fd6aa12.js.map +0 -1
- package/dist/LanguageChoice.1579b654.js.map +0 -1
- package/dist/LanguageChoice.61e36c1d.js.map +0 -1
- package/dist/NewsContainer.67f04b19.js.map +0 -1
- package/dist/NewsContainer.932174e9.js.map +0 -1
- package/dist/Weather.661c2cac.js.map +0 -1
- package/dist/Weather.fb22fba3.js.map +0 -1
package/dist/index.modern.js
CHANGED
|
@@ -10,7 +10,7 @@ import {ConnectionStatus as $bZRJW$ConnectionStatus, DirectLine as $bZRJW$Direct
|
|
|
10
10
|
import {Document as $bZRJW$Document, Page as $bZRJW$Page, pdfjs as $bZRJW$pdfjs} from "react-pdf";
|
|
11
11
|
import {animated as $bZRJW$animated, useSpring as $bZRJW$useSpring, easings as $bZRJW$easings} from "@react-spring/web";
|
|
12
12
|
import {Player as $bZRJW$Player} from "@lottiefiles/react-lottie-player";
|
|
13
|
-
import {browserName as $bZRJW$browserName, BrowserTypes as $bZRJW$BrowserTypes, osName as $bZRJW$osName, OsTypes as $bZRJW$OsTypes,
|
|
13
|
+
import {browserName as $bZRJW$browserName, BrowserTypes as $bZRJW$BrowserTypes, osName as $bZRJW$osName, OsTypes as $bZRJW$OsTypes, isMobile as $bZRJW$isMobile} from "react-device-detect";
|
|
14
14
|
import {presets as $d70757f720801c36$re_export$presets} from "@davi-ai/react-bodyengine-three";
|
|
15
15
|
import {createRoot as $bZRJW$createRoot} from "react-dom/client";
|
|
16
16
|
import $bZRJW$reactshadow from "react-shadow";
|
|
@@ -90,7 +90,6 @@ const $920719987d28bd50$var$initialState = {
|
|
|
90
90
|
retorikEvent: undefined,
|
|
91
91
|
displayAgent: true,
|
|
92
92
|
activityToSend: undefined,
|
|
93
|
-
currentNewsActivity: undefined,
|
|
94
93
|
retorikNewsEnded: false,
|
|
95
94
|
userIsTyping: false,
|
|
96
95
|
userIsSwiping: false,
|
|
@@ -176,11 +175,6 @@ const $920719987d28bd50$var$createUtilsStore = ()=>(0, $bZRJW$createStore)((set,
|
|
|
176
175
|
activityToSend: value
|
|
177
176
|
});
|
|
178
177
|
},
|
|
179
|
-
setCurrentNewsActivity: (value)=>{
|
|
180
|
-
set({
|
|
181
|
-
currentNewsActivity: value
|
|
182
|
-
});
|
|
183
|
-
},
|
|
184
178
|
setRetorikNewsEnded: (value)=>{
|
|
185
179
|
set({
|
|
186
180
|
retorikNewsEnded: value
|
|
@@ -338,6 +332,7 @@ $parcel$export(module.exports, "Source3DEngine", () => $179a76b9823b36f3$export$
|
|
|
338
332
|
$parcel$export(module.exports, "UIPart", () => $179a76b9823b36f3$export$63fc5f52b5b4da1e);
|
|
339
333
|
$parcel$export(module.exports, "TextFrom", () => $179a76b9823b36f3$export$b685c7d489184507);
|
|
340
334
|
$parcel$export(module.exports, "Theme", () => $179a76b9823b36f3$export$14faa19a0f3bbeb2);
|
|
335
|
+
$parcel$export(module.exports, "TraceType", () => $179a76b9823b36f3$export$d4b4ca0ba30ae29c);
|
|
341
336
|
var $179a76b9823b36f3$export$e4a712fff93fb00f = /*#__PURE__*/ function(ActionType) {
|
|
342
337
|
ActionType["message"] = "message";
|
|
343
338
|
ActionType["event"] = "event";
|
|
@@ -563,6 +558,12 @@ var $179a76b9823b36f3$export$14faa19a0f3bbeb2 = /*#__PURE__*/ function(Theme) {
|
|
|
563
558
|
Theme["auto"] = "auto";
|
|
564
559
|
return Theme;
|
|
565
560
|
}($179a76b9823b36f3$export$14faa19a0f3bbeb2 || {});
|
|
561
|
+
var $179a76b9823b36f3$export$d4b4ca0ba30ae29c = /*#__PURE__*/ function(TraceType) {
|
|
562
|
+
TraceType["message"] = "directlineMessage";
|
|
563
|
+
TraceType["utteranceStart"] = "utteranceStart";
|
|
564
|
+
TraceType["utteranceEnd"] = "utteranceEnd";
|
|
565
|
+
return TraceType;
|
|
566
|
+
}($179a76b9823b36f3$export$d4b4ca0ba30ae29c || {});
|
|
566
567
|
|
|
567
568
|
});
|
|
568
569
|
|
|
@@ -2061,9 +2062,6 @@ const $244e94971d503466$var$initialState = {
|
|
|
2061
2062
|
visemeData: [],
|
|
2062
2063
|
singleVisemeAdded: null,
|
|
2063
2064
|
multiVisemesAdded: [],
|
|
2064
|
-
currentReplyToId: undefined,
|
|
2065
|
-
currentPlaying: undefined,
|
|
2066
|
-
endedActivities: [],
|
|
2067
2065
|
currentOrLastPlayedActivity: undefined,
|
|
2068
2066
|
isMicrophoneAllowed: false,
|
|
2069
2067
|
showMicrophoneModal: false,
|
|
@@ -2072,9 +2070,6 @@ const $244e94971d503466$var$initialState = {
|
|
|
2072
2070
|
lastRecognitionInterim: '',
|
|
2073
2071
|
streamingReplyToId: null,
|
|
2074
2072
|
streamingQueue: [],
|
|
2075
|
-
streamingQueueForText: [],
|
|
2076
|
-
currentStreaming: null,
|
|
2077
|
-
streamingQueueFullLength: 0,
|
|
2078
2073
|
streamingReplyToIdToIgnore: null,
|
|
2079
2074
|
speechRecognitionDynamicGrammars: [],
|
|
2080
2075
|
externalTextToSpeech: undefined
|
|
@@ -2210,22 +2205,6 @@ const $244e94971d503466$var$createSpeechStore = (setRetorikEvent, getListStatus,
|
|
|
2210
2205
|
if (getListStatus() !== (0, $4ucVo.ListStatus).opened) setListStatus((0, $4ucVo.ListStatus).available);
|
|
2211
2206
|
}
|
|
2212
2207
|
},
|
|
2213
|
-
setCurrentReplyToId: (value)=>{
|
|
2214
|
-
set({
|
|
2215
|
-
currentReplyToId: value
|
|
2216
|
-
});
|
|
2217
|
-
},
|
|
2218
|
-
setCurrentPlaying: (value)=>{
|
|
2219
|
-
set({
|
|
2220
|
-
currentPlaying: value
|
|
2221
|
-
});
|
|
2222
|
-
value && get().actions.setCurrentOrLastPlayedActivity(value);
|
|
2223
|
-
},
|
|
2224
|
-
setEndedActivities: (value)=>{
|
|
2225
|
-
set({
|
|
2226
|
-
endedActivities: value
|
|
2227
|
-
});
|
|
2228
|
-
},
|
|
2229
2208
|
setIsMicrophoneAllowed: (value)=>{
|
|
2230
2209
|
set({
|
|
2231
2210
|
isMicrophoneAllowed: value
|
|
@@ -2287,72 +2266,45 @@ const $244e94971d503466$var$createSpeechStore = (setRetorikEvent, getListStatus,
|
|
|
2287
2266
|
streamingReplyToId: value
|
|
2288
2267
|
});
|
|
2289
2268
|
},
|
|
2290
|
-
setStreamingQueue: (value)=>{
|
|
2291
|
-
set({
|
|
2292
|
-
streamingQueue: value,
|
|
2293
|
-
streamingQueueForText: value
|
|
2294
|
-
});
|
|
2295
|
-
},
|
|
2296
2269
|
addToStreamingQueue: (value)=>{
|
|
2297
|
-
if (value.replyToId
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
}
|
|
2270
|
+
if (value.replyToId) {
|
|
2271
|
+
if (value.replyToId !== get().streamingReplyToIdToIgnore) {
|
|
2272
|
+
// Set replyToId and new queue if replyToId is different from the current one
|
|
2273
|
+
if (get().streamingReplyToId !== value.replyToId) set({
|
|
2274
|
+
streamingReplyToId: value.replyToId,
|
|
2275
|
+
streamingQueue: [
|
|
2276
|
+
value
|
|
2277
|
+
]
|
|
2278
|
+
});
|
|
2279
|
+
else set({
|
|
2280
|
+
streamingQueue: [
|
|
2281
|
+
...get().streamingQueue,
|
|
2282
|
+
value
|
|
2283
|
+
]
|
|
2284
|
+
});
|
|
2285
|
+
}
|
|
2286
|
+
} else set({
|
|
2287
|
+
streamingQueue: [
|
|
2288
|
+
...get().streamingQueue,
|
|
2289
|
+
value
|
|
2290
|
+
]
|
|
2291
|
+
});
|
|
2320
2292
|
},
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
streamingQueue: tempStreamingQueue
|
|
2327
|
-
});
|
|
2328
|
-
}
|
|
2293
|
+
// If "twice" parameter is true, let's remove 2 elements instead of one (used with the message at the end of a streaming that should not be spoken)
|
|
2294
|
+
removeFirstFromStreamingQueue: (twice)=>{
|
|
2295
|
+
set((state)=>({
|
|
2296
|
+
streamingQueue: state.streamingQueue.slice(twice ? 2 : 1)
|
|
2297
|
+
}));
|
|
2329
2298
|
},
|
|
2330
2299
|
killCurrentStreaming: ()=>{
|
|
2331
2300
|
set({
|
|
2332
|
-
|
|
2333
|
-
streamingQueue: []
|
|
2334
|
-
streamingQueueForText: [],
|
|
2335
|
-
currentStreaming: null,
|
|
2336
|
-
streamingQueueFullLength: 0,
|
|
2337
|
-
streamingReplyToIdToIgnore: get().streamingReplyToId
|
|
2301
|
+
streamingReplyToIdToIgnore: get().streamingReplyToId,
|
|
2302
|
+
streamingQueue: []
|
|
2338
2303
|
});
|
|
2339
2304
|
},
|
|
2340
2305
|
checkActivityReplyToId: (replyToId)=>{
|
|
2341
2306
|
get().streamingReplyToId !== replyToId && get().actions.killCurrentStreaming();
|
|
2342
2307
|
},
|
|
2343
|
-
setCurrentStreaming: (value)=>{
|
|
2344
|
-
set({
|
|
2345
|
-
currentStreaming: value
|
|
2346
|
-
});
|
|
2347
|
-
},
|
|
2348
|
-
setStreamingQueueFullLength: (value, replyToId)=>{
|
|
2349
|
-
if (replyToId) replyToId === get().streamingReplyToId && set({
|
|
2350
|
-
streamingQueueFullLength: value
|
|
2351
|
-
});
|
|
2352
|
-
else set({
|
|
2353
|
-
streamingQueueFullLength: value
|
|
2354
|
-
});
|
|
2355
|
-
},
|
|
2356
2308
|
addSpeechRecognitionDynamicGrammar: (value)=>{
|
|
2357
2309
|
const currentGrammars = get().speechRecognitionDynamicGrammars;
|
|
2358
2310
|
// For each value, verifiy if it doesn't exist in the array yet
|
|
@@ -2772,7 +2724,7 @@ const $1cd684302a8789ac$var$initialState = {
|
|
|
2772
2724
|
queueLock: false
|
|
2773
2725
|
};
|
|
2774
2726
|
const $1cd684302a8789ac$var$regexDataCommand = /(\{data-command=")[\p{L}\p{N}\p{Po}\p{Pd}\p{Pc}\s\u0027\u2019]+("\})(<br\s\/>)?/gu;
|
|
2775
|
-
const $1cd684302a8789ac$var$createActivityStore = (localeRef, isUsedOnBorneRef, inputHintBehaviourRef, setCurrentId, setRestoreInputsState, addToStreamingQueue,
|
|
2727
|
+
const $1cd684302a8789ac$var$createActivityStore = (localeRef, isUsedOnBorneRef, inputHintBehaviourRef, setCurrentId, setRestoreInputsState, addToStreamingQueue, setMode, unlockClickedButton, setSubmitDelayBeforeSendingMessage, setIsWaitingForResponse, setSendBoxPlaceHolder)=>{
|
|
2776
2728
|
return (0, $bZRJW$createStore)((set, get)=>{
|
|
2777
2729
|
return {
|
|
2778
2730
|
...$1cd684302a8789ac$var$initialState,
|
|
@@ -2837,7 +2789,7 @@ const $1cd684302a8789ac$var$createActivityStore = (localeRef, isUsedOnBorneRef,
|
|
|
2837
2789
|
currentActivity.type === 'message' ? await get().actions.processAddBotMessage(currentActivity) : await get().actions.processAddBotEvent(currentActivity);
|
|
2838
2790
|
// Remove the first element from the queue (the one that got processed above) and process the queue once again
|
|
2839
2791
|
set({
|
|
2840
|
-
queue: get().queue.slice(
|
|
2792
|
+
queue: get().queue.slice(1)
|
|
2841
2793
|
});
|
|
2842
2794
|
get().actions.processQueue();
|
|
2843
2795
|
} else set({
|
|
@@ -2847,9 +2799,9 @@ const $1cd684302a8789ac$var$createActivityStore = (localeRef, isUsedOnBorneRef,
|
|
|
2847
2799
|
processAddBotMessage: async (value)=>{
|
|
2848
2800
|
setCurrentId(undefined);
|
|
2849
2801
|
const processedActivity = await get().actions.processBotMessageActivity(value);
|
|
2850
|
-
// If this activity is the one concluding a streaming, let's set the amount of streams previously generated
|
|
2851
|
-
if (!get().retrievingConversation && value.value?.streamingCount) setStreamingQueueFullLength(value.value.streamingCount, value.replyToId);
|
|
2852
2802
|
const tempActivity = get().retrievingConversation ? undefined : processedActivity;
|
|
2803
|
+
// Add this activity to the streaming queue if we are not in conversation retrieval process
|
|
2804
|
+
!get().retrievingConversation && addToStreamingQueue(processedActivity);
|
|
2853
2805
|
set({
|
|
2854
2806
|
activities: [
|
|
2855
2807
|
...get().activities,
|
|
@@ -2891,6 +2843,28 @@ const $1cd684302a8789ac$var$createActivityStore = (localeRef, isUsedOnBorneRef,
|
|
|
2891
2843
|
}
|
|
2892
2844
|
},
|
|
2893
2845
|
processAddBotEvent: async (value)=>{
|
|
2846
|
+
const streamingMap = new Map(get().botStreamingActivities);
|
|
2847
|
+
// Deal with streaming activities
|
|
2848
|
+
if (value.name?.toLowerCase() === 'davi.streammessageactivity') // Add this activity to the streaming queue if we are not in conversation retrieval process
|
|
2849
|
+
{
|
|
2850
|
+
if (value.text?.trim().length && !get().retrievingConversation) {
|
|
2851
|
+
// Create speak field from the text one
|
|
2852
|
+
const processedText = (0, $dklvz.processMarkdownAndSpeechMarkdown)(value.text, true);
|
|
2853
|
+
value.speak = processedText.text;
|
|
2854
|
+
value.htmlText = processedText.htmlText;
|
|
2855
|
+
addToStreamingQueue(value);
|
|
2856
|
+
// Set data in the Map for text display
|
|
2857
|
+
if (value.replyToId) {
|
|
2858
|
+
const currentStreamingData = streamingMap.get(value.replyToId);
|
|
2859
|
+
currentStreamingData ? streamingMap.set(value.replyToId, [
|
|
2860
|
+
...currentStreamingData,
|
|
2861
|
+
value
|
|
2862
|
+
]) : streamingMap.set(value.replyToId, [
|
|
2863
|
+
value
|
|
2864
|
+
]);
|
|
2865
|
+
}
|
|
2866
|
+
}
|
|
2867
|
+
}
|
|
2894
2868
|
set({
|
|
2895
2869
|
activities: [
|
|
2896
2870
|
...get().activities,
|
|
@@ -2908,37 +2882,15 @@ const $1cd684302a8789ac$var$createActivityStore = (localeRef, isUsedOnBorneRef,
|
|
|
2908
2882
|
],
|
|
2909
2883
|
lastBotEventActivity: value,
|
|
2910
2884
|
lastEventActivity: value,
|
|
2885
|
+
botStreamingActivities: streamingMap,
|
|
2911
2886
|
watermark: get().watermark + 1
|
|
2912
2887
|
});
|
|
2913
2888
|
Promise.resolve();
|
|
2914
2889
|
},
|
|
2915
2890
|
addBotEvent: async (value)=>{
|
|
2916
2891
|
if (get().actions.checkCurrentConversationId(value.id)) {
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
setIsWaitingForResponse(false);
|
|
2920
|
-
// Create speak field from the text one
|
|
2921
|
-
const processedText = (0, $dklvz.processMarkdownAndSpeechMarkdown)(value.text, true);
|
|
2922
|
-
value.speak = processedText.text;
|
|
2923
|
-
value.htmlText = processedText.htmlText;
|
|
2924
|
-
addToStreamingQueue(value);
|
|
2925
|
-
if (value.replyToId) {
|
|
2926
|
-
const currentStreamingMap = new Map(get().botStreamingActivities);
|
|
2927
|
-
const currentStreamingData = currentStreamingMap.get(value.replyToId);
|
|
2928
|
-
currentStreamingData ? currentStreamingMap.set(value.replyToId, [
|
|
2929
|
-
...currentStreamingData,
|
|
2930
|
-
value
|
|
2931
|
-
]) : currentStreamingMap.set(value.replyToId, [
|
|
2932
|
-
value
|
|
2933
|
-
]);
|
|
2934
|
-
set({
|
|
2935
|
-
botStreamingActivities: currentStreamingMap,
|
|
2936
|
-
watermark: get().watermark + 1
|
|
2937
|
-
});
|
|
2938
|
-
}
|
|
2939
|
-
unlockClickedButton();
|
|
2940
|
-
}
|
|
2941
|
-
} else if (value.name?.toLowerCase() === 'switchtotextmode') {
|
|
2892
|
+
//
|
|
2893
|
+
if (value.name?.toLowerCase() === 'switchtotextmode') {
|
|
2942
2894
|
setMode((0, $4ucVo.Mode).text);
|
|
2943
2895
|
set({
|
|
2944
2896
|
watermark: get().watermark + 1
|
|
@@ -3203,10 +3155,10 @@ const $1cd684302a8789ac$var$ActivityProvider = ({ children: children })=>{
|
|
|
3203
3155
|
const isUsedOnBorneRef = (0, $bZRJW$useRef)(false);
|
|
3204
3156
|
const inputHintBehaviourRef = (0, $bZRJW$useRef)(undefined);
|
|
3205
3157
|
const { setCurrentId: setCurrentId, setRestoreInputsState: setRestoreInputsState } = (0, $jubFc.useAdaptiveCardStore)((state)=>state.actions);
|
|
3206
|
-
const { addToStreamingQueue: addToStreamingQueue,
|
|
3158
|
+
const { addToStreamingQueue: addToStreamingQueue, setMode: setMode } = (0, $i1rfm.useSpeechStore)((state)=>state.actions);
|
|
3207
3159
|
const unlockClickedButton = (0, $j67YK.useUtilsStore)((state)=>state.actions.unlockClickedButton);
|
|
3208
3160
|
const { setSubmitDelayBeforeSendingMessage: setSubmitDelayBeforeSendingMessage, setIsWaitingForResponse: setIsWaitingForResponse, setSendBoxPlaceHolder: setSendBoxPlaceHolder } = (0, $1x02c.useRetorikStore)((state)=>state.actions);
|
|
3209
|
-
const [store] = (0, $bZRJW$useState)(()=>$1cd684302a8789ac$var$createActivityStore(localeRef, isUsedOnBorneRef, inputHintBehaviourRef, setCurrentId, setRestoreInputsState, addToStreamingQueue,
|
|
3161
|
+
const [store] = (0, $bZRJW$useState)(()=>$1cd684302a8789ac$var$createActivityStore(localeRef, isUsedOnBorneRef, inputHintBehaviourRef, setCurrentId, setRestoreInputsState, addToStreamingQueue, setMode, unlockClickedButton, setSubmitDelayBeforeSendingMessage, setIsWaitingForResponse, setSendBoxPlaceHolder));
|
|
3210
3162
|
(0, $bZRJW$useEffect)(()=>{
|
|
3211
3163
|
localeRef.current = locale;
|
|
3212
3164
|
}, [
|
|
@@ -4127,7 +4079,7 @@ const $ca466c72d380f23a$var$createDirectlineStore = (modeRef, recognitionStateRe
|
|
|
4127
4079
|
if (get().actions.checkIfHandlerAbortsActivity((0, $1ZPEZ.LegacyDirectLineActivityType).SEND_MESSAGE, tempActivity)) return;
|
|
4128
4080
|
get().directLine?.postActivity(tempActivity).subscribe();
|
|
4129
4081
|
},
|
|
4130
|
-
sendEvent: (name, value)=>{
|
|
4082
|
+
sendEvent: (name, value, callback)=>{
|
|
4131
4083
|
if (get().conversationPaused) return;
|
|
4132
4084
|
!name.toLowerCase().includes('davi.closewindow') && !$ca466c72d380f23a$var$eventsWithoutCancel.includes(name.toLowerCase()) && get().actions.checkMicrophoneAndCancel();
|
|
4133
4085
|
const locale = checkDumpedLocaleFallback();
|
|
@@ -4146,7 +4098,10 @@ const $ca466c72d380f23a$var$createDirectlineStore = (modeRef, recognitionStateRe
|
|
|
4146
4098
|
// Check if the event should be stopped in the external activity handler if there is one
|
|
4147
4099
|
if (get().actions.checkIfHandlerAbortsActivity((0, $1ZPEZ.LegacyDirectLineActivityType).POST_ACTIVITY, tempEvent)) return;
|
|
4148
4100
|
if (get().actions.checkIfHandlerAbortsActivity((0, $1ZPEZ.LegacyDirectLineActivityType).SEND_EVENT, tempEvent)) return;
|
|
4149
|
-
get().directLine?.postActivity(tempEvent).subscribe(
|
|
4101
|
+
get().directLine?.postActivity(tempEvent).subscribe({
|
|
4102
|
+
error: (error)=>console.log('Retorik Framework > error while sending event : ', error),
|
|
4103
|
+
complete: ()=>callback?.()
|
|
4104
|
+
});
|
|
4150
4105
|
},
|
|
4151
4106
|
sendTyping: ()=>{
|
|
4152
4107
|
if (get().conversationPaused) return;
|
|
@@ -4352,7 +4307,7 @@ var $c54ebc4ba0100ff1$export$2e2bcd8739ae039 = $c54ebc4ba0100ff1$var$activityMid
|
|
|
4352
4307
|
});
|
|
4353
4308
|
|
|
4354
4309
|
parcelRegister("iT1WI", function(module, exports) {
|
|
4355
|
-
module.exports = JSON.parse("{\"name\":\"@davi-ai/retorik-framework\",\"version\":\"3.2.
|
|
4310
|
+
module.exports = JSON.parse("{\"name\":\"@davi-ai/retorik-framework\",\"version\":\"3.2.4\",\"description\":\"Retorik Framework package\",\"author\":\"DAVI\",\"license\":\"MIT\",\"repository\":\"none\",\"main\":\"dist/index.js\",\"module\":\"dist/index.modern.js\",\"types\":\"dist/index.d.ts\",\"source\":\"src/index.tsx\",\"standalone\":\"standalone/index.js\",\"targets\":{\"standalone\":{\"context\":\"browser\",\"outputFormat\":\"esmodule\",\"distDir\":\"standalone\"},\"module\":{\"context\":\"browser\",\"outputFormat\":\"esmodule\",\"distDir\":\"dist\"}},\"engines\":{\"node\":\">=10\"},\"scripts\":{\"build\":\"parcel build\",\"start\":\"parcel watch\",\"test\":\"jest --env=jsdom --reporters=jest-junit\",\"test-console\":\"jest --env=jsdom\",\"test-update-snapshots\":\"jest --env=jsdom --updateSnapshot\",\"test-coverage-console\":\"jest --env=jsdom --reporters=jest-junit --coverage\",\"test-coverage\":\"jest --env=jsdom --reporters=jest-junit --coverage --coverageReporters=cobertura\",\"report\":\"npx parcel build src/index.tsx --reporter @parcel/reporter-bundle-analyzer\",\"credentials\":\"vsts-npm-auth -config .npmrc\"},\"peerDependencies\":{\"react\":\"18.3.1\",\"react-dom\":\"18.3.1\"},\"devDependencies\":{\"@babel/core\":\"^7.19.1\",\"@babel/plugin-proposal-decorators\":\"^7.24.7\",\"@babel/plugin-proposal-private-property-in-object\":\"^7.21.11\",\"@babel/preset-env\":\"^7.25.4\",\"@babel/preset-react\":\"^7.24.7\",\"@babel/preset-typescript\":\"^7.24.7\",\"@babel/runtime\":\"^7.23.8\",\"@parcel/packager-ts\":\"^2.13.2\",\"@parcel/reporter-bundle-analyzer\":\"^2.13.2\",\"@parcel/reporter-sourcemap-visualiser\":\"^2.13.2\",\"@parcel/transformer-inline-string\":\"^2.13.2\",\"@parcel/transformer-typescript-types\":\"^2.13.2\",\"@parcel/validator-eslint\":\"^2.13.2\",\"@parcel/validator-typescript\":\"^2.13.2\",\"@testing-library/dom\":\"^10.4.0\",\"@testing-library/jest-dom\":\"6.5.0\",\"@testing-library/react\":\"16.0.1\",\"@testing-library/react-hooks\":\"8.0.1\",\"@testing-library/user-event\":\"14.5.2\",\"@types/jest\":\"^27.5.1\",\"@types/leaflet\":\"^1.8.0\",\"@types/node\":\"^12.12.38\",\"@types/react\":\"18.3.12\",\"@types/react-dom\":\"18.3.1\",\"@types/testing-library__jest-dom\":\"^5.14.5\",\"@types/testing-library__react\":\"latest\",\"@typescript-eslint/eslint-plugin\":\"^8.19.0\",\"@typescript-eslint/parser\":\"^8.19.0\",\"autoprefixer\":\"^10.4.7\",\"babel-eslint\":\"^10.0.3\",\"babel-jest\":\"^29.7.0\",\"babel-loader\":\"^8.2.5\",\"buffer\":\"^5.7.1\",\"canvas\":\"^2.9.0\",\"cross-env\":\"^7.0.2\",\"crypto-browserify\":\"^3.12.0\",\"eslint\":\"^9.16.0\",\"eslint-config-prettier\":\"^9.1.0\",\"eslint-config-standard\":\"^17.1.0\",\"eslint-config-standard-react\":\"^13.0.0\",\"eslint-plugin-import\":\"^2.31.0\",\"eslint-plugin-node\":\"^11.1.0\",\"eslint-plugin-prettier\":\"^5.2.1\",\"eslint-plugin-promise\":\"^7.2.1\",\"eslint-plugin-react\":\"^7.37.2\",\"https-browserify\":\"^1.0.0\",\"jest\":\"^29.7.0\",\"jest-environment-jsdom\":\"^29.7.0\",\"jest-junit\":\"16.0.0\",\"npm-run-all\":\"^4.1.5\",\"parcel\":\"^2.13.2\",\"postcss\":\"^8.4.14\",\"postcss-url\":\"^10.1.3\",\"prettier\":\"^2.0.4\",\"process\":\"^0.11.10\",\"punycode\":\"^1.4.1\",\"querystring-es3\":\"^0.2.1\",\"react\":\"^18\",\"react-docgen-typescript-plugin\":\"^1.0.5\",\"react-dom\":\"18.3.1\",\"react-test-renderer\":\"^18.3.1\",\"resize-observer-polyfill\":\"^1.5.1\",\"stream-browserify\":\"^3.0.0\",\"stream-http\":\"^3.2.0\",\"string_decoder\":\"^1.3.0\",\"tailwindcss\":\"^3.1.0\",\"typescript\":\"5.3.2\",\"url\":\"^0.11.0\",\"util\":\"^0.12.4\"},\"files\":[\"dist\"],\"dependencies\":{\"@davi-ai/body-engine-sprite\":\"3.0.0\",\"@davi-ai/react-bodyengine-three\":\"1.0.6\",\"@davi-ai/retorik-weather\":\"2.0.0\",\"@davi-ai/speechmarkdown-davi-js\":\"2.0.1\",\"@davi-ai/web-speech-cognitive-services-davi\":\"2.0.10\",\"@lottiefiles/react-lottie-player\":\"^3.4.1\",\"@opentelemetry/api\":\"^1.9.0\",\"@opentelemetry/exporter-trace-otlp-http\":\"^0.200.0\",\"@opentelemetry/instrumentation\":\"^0.200.0\",\"@opentelemetry/instrumentation-document-load\":\"^0.45.0\",\"@opentelemetry/instrumentation-fetch\":\"^0.200.0\",\"@opentelemetry/resources\":\"^2.0.0\",\"@opentelemetry/sdk-trace-web\":\"^2.0.0\",\"@opentelemetry/semantic-conventions\":\"^1.32.0\",\"@react-spring/types\":\"^9.7.3\",\"@react-spring/web\":\"^9.7.3\",\"@swc/helpers\":\"^0.5.0\",\"@types/geojson\":\"^7946.0.10\",\"@types/jsdom\":\"^16.2.14\",\"@use-gesture/react\":\"^10.2.15\",\"adaptivecards\":\"3.0.1\",\"botframework-directlinejs\":\"^0.15.5\",\"classnames\":\"^2.3.1\",\"detect-gpu\":\"^5.0.70\",\"leaflet\":\"^1.9.2\",\"markdown-it\":\"14.1.0\",\"pdfjs-dist\":\"3.11.174\",\"postcss-copy\":\"^7.1.0\",\"qrcode\":\"^1.5.1\",\"react-device-detect\":\"^2.2.3\",\"react-error-boundary\":\"^4.0.10\",\"react-leaflet\":\"^4.1.0\",\"react-pdf\":\"7.7.1\",\"react-shadow\":\"^20.5.0\",\"swiper\":\"^8.4.5\",\"zustand\":\"^5.0.3\"},\"overrides\":{\"@davi-ai/web-speech-cognitive-services-davi\":\"$@davi-ai/web-speech-cognitive-services-davi\",\"zustand\":\"$zustand\"},\"@parcel/resolver-default\":{\"packageExports\":true}}");
|
|
4356
4311
|
|
|
4357
4312
|
});
|
|
4358
4313
|
|
|
@@ -5466,23 +5421,24 @@ const $04f538c5adcaba69$var$SendActivityEventListener = ({ isRetorikNews: isReto
|
|
|
5466
5421
|
document.removeEventListener('retorikSetVisibility', handleEvents);
|
|
5467
5422
|
};
|
|
5468
5423
|
}, []);
|
|
5469
|
-
|
|
5470
|
-
|
|
5471
|
-
|
|
5472
|
-
|
|
5473
|
-
|
|
5474
|
-
|
|
5424
|
+
/**
|
|
5425
|
+
* Send mandatory events : setUser to start conversation, Davi.GDPRConsent for GDPR module
|
|
5426
|
+
*/ const sendMandatoryEvents = async ()=>{
|
|
5427
|
+
sendEvent('Davi.GDPRConsent', {
|
|
5428
|
+
userConsent: userConsent
|
|
5429
|
+
}, ()=>sendEvent('setUser', {
|
|
5475
5430
|
user: {
|
|
5476
5431
|
...userData,
|
|
5477
5432
|
gdprConsent: true
|
|
5478
5433
|
},
|
|
5479
5434
|
skipWelcome: !!skipWelcome
|
|
5480
|
-
});
|
|
5481
|
-
|
|
5482
|
-
|
|
5483
|
-
|
|
5484
|
-
|
|
5485
|
-
|
|
5435
|
+
}));
|
|
5436
|
+
};
|
|
5437
|
+
(0, $bZRJW$useEffect)(()=>{
|
|
5438
|
+
if (isRetorikNews || hasConversationCookie) setUserAlreadySet(true);
|
|
5439
|
+
else if (!userAlreadySet && appAvailable && !displayGDPR && characterLoaded) {
|
|
5440
|
+
setUserAlreadySet(true);
|
|
5441
|
+
sendMandatoryEvents();
|
|
5486
5442
|
}
|
|
5487
5443
|
}, [
|
|
5488
5444
|
appAvailable,
|
|
@@ -7695,8 +7651,7 @@ const $2ec58e0e10234435$var$List = ({ activity: activity, onClose: onClose })=>{
|
|
|
7695
7651
|
if (timerRef) {
|
|
7696
7652
|
timerRef.current && clearTimeout(timerRef.current);
|
|
7697
7653
|
timerRef.current = setTimeout(()=>{
|
|
7698
|
-
sendEvent('Davi.CloseWindow', null);
|
|
7699
|
-
sendEvent('Davi.CloseWindowList', null);
|
|
7654
|
+
sendEvent('Davi.CloseWindow', null, ()=>sendEvent('Davi.CloseWindowList', null));
|
|
7700
7655
|
onClose?.();
|
|
7701
7656
|
setContent(undefined);
|
|
7702
7657
|
}, $2ec58e0e10234435$var$springLeaveDuration);
|
|
@@ -7756,7 +7711,6 @@ const $2ec58e0e10234435$var$List = ({ activity: activity, onClose: onClose })=>{
|
|
|
7756
7711
|
(0, $bZRJW$useEffect)(()=>{
|
|
7757
7712
|
handleOpen();
|
|
7758
7713
|
return ()=>{
|
|
7759
|
-
console.log('in return');
|
|
7760
7714
|
setListStatus((0, $4ucVo.ListStatus).closed);
|
|
7761
7715
|
timerRef?.current && clearTimeout(timerRef.current);
|
|
7762
7716
|
};
|
|
@@ -15295,17 +15249,17 @@ var $2ebe7b2fda999dc7$export$2e2bcd8739ae039 = $2ebe7b2fda999dc7$var$Grid;
|
|
|
15295
15249
|
|
|
15296
15250
|
|
|
15297
15251
|
parcelRegister("6EXzm", function(module, exports) {
|
|
15298
|
-
module.exports = import("./HistoryList.
|
|
15252
|
+
module.exports = import("./HistoryList.03a56119.js").then(()=>parcelRequire('2IZpO'));
|
|
15299
15253
|
|
|
15300
15254
|
});
|
|
15301
15255
|
|
|
15302
15256
|
parcelRegister("rAdI8", function(module, exports) {
|
|
15303
|
-
module.exports = import("./LanguageChoice.
|
|
15257
|
+
module.exports = import("./LanguageChoice.623ee802.js").then(()=>parcelRequire('4HBCW'));
|
|
15304
15258
|
|
|
15305
15259
|
});
|
|
15306
15260
|
|
|
15307
15261
|
parcelRegister("8y5Zs", function(module, exports) {
|
|
15308
|
-
module.exports = import("./AttachmentDetail.
|
|
15262
|
+
module.exports = import("./AttachmentDetail.fdcd1737.js").then(()=>parcelRequire('8QAGm'));
|
|
15309
15263
|
|
|
15310
15264
|
});
|
|
15311
15265
|
|
|
@@ -15315,17 +15269,17 @@ module.exports = import("./FullScreenImage.1fe27198.js").then(()=>parcelRequire(
|
|
|
15315
15269
|
});
|
|
15316
15270
|
|
|
15317
15271
|
parcelRegister("5Lxsr", function(module, exports) {
|
|
15318
|
-
module.exports = import("./Weather.
|
|
15272
|
+
module.exports = import("./Weather.cf58823d.js").then(()=>parcelRequire('2pbjN'));
|
|
15319
15273
|
|
|
15320
15274
|
});
|
|
15321
15275
|
|
|
15322
15276
|
parcelRegister("4tkZ7", function(module, exports) {
|
|
15323
|
-
module.exports = import("./CustomView.
|
|
15277
|
+
module.exports = import("./CustomView.c24a0e74.js").then(()=>parcelRequire('5s7df'));
|
|
15324
15278
|
|
|
15325
15279
|
});
|
|
15326
15280
|
|
|
15327
15281
|
parcelRegister("i6zhG", function(module, exports) {
|
|
15328
|
-
module.exports = import("./Emergency.
|
|
15282
|
+
module.exports = import("./Emergency.0cf005ce.js").then(()=>parcelRequire('4zoun'));
|
|
15329
15283
|
|
|
15330
15284
|
});
|
|
15331
15285
|
|
|
@@ -17104,6 +17058,11 @@ const $64c0a3f23b72e5d5$var$MicrophoneTextBubble = ({ showLoader: showLoader })=
|
|
|
17104
17058
|
const [text, setText] = (0, $bZRJW$useState)();
|
|
17105
17059
|
const [textUndefined, setTextUndefined] = (0, $bZRJW$useState)(false);
|
|
17106
17060
|
const timerRef = (0, $bZRJW$useRef)(null);
|
|
17061
|
+
(0, $bZRJW$useEffect)(()=>{
|
|
17062
|
+
return ()=>{
|
|
17063
|
+
timerRef.current && clearTimeout(timerRef.current);
|
|
17064
|
+
};
|
|
17065
|
+
}, []);
|
|
17107
17066
|
(0, $bZRJW$useEffect)(()=>{
|
|
17108
17067
|
setTextUndefined(speaking || showLoader || !botAnswerEnded || currentSubView !== (0, $4ucVo.CurrentSubView).none || dashboardOpened || retorikEvent === (0, $4ucVo.RetorikEvent).DetailViewOpen || listStatus === (0, $4ucVo.ListStatus).opened);
|
|
17109
17068
|
}, [
|
|
@@ -17133,8 +17092,12 @@ const $64c0a3f23b72e5d5$var$MicrophoneTextBubble = ({ showLoader: showLoader })=
|
|
|
17133
17092
|
setText(isMobile || isLandscape && lastRecognitionInterim ? undefined : translation.microphone.listening);
|
|
17134
17093
|
break;
|
|
17135
17094
|
case (0, $4ucVo.RecognitionState).Closed:
|
|
17136
|
-
|
|
17137
|
-
|
|
17095
|
+
let text = undefined;
|
|
17096
|
+
if (!textUndefined) text = useContinuousRecognition ? `<p>${translation.microphone.trigger}${isMobile ? ' ' : '<br />'}<strong>\xab ${agentData?.name} \xbb</strong></p>` : `<p>${translation.microphone.triggerwithoutname}</p>`;
|
|
17097
|
+
// Show the button only 1.5s after, to prevents it from appearing à fraction of second between several texts
|
|
17098
|
+
timerRef.current = setTimeout(()=>{
|
|
17099
|
+
setText(text);
|
|
17100
|
+
}, 1500);
|
|
17138
17101
|
break;
|
|
17139
17102
|
case (0, $4ucVo.RecognitionState).Initializing:
|
|
17140
17103
|
case (0, $4ucVo.RecognitionState).Closing:
|
|
@@ -18774,7 +18737,7 @@ var $af2bd3eba7cc813c$export$2e2bcd8739ae039 = $af2bd3eba7cc813c$var$DashboardIt
|
|
|
18774
18737
|
|
|
18775
18738
|
|
|
18776
18739
|
parcelRegister("lNCSW", function(module, exports) {
|
|
18777
|
-
module.exports = import("./NewsContainer.
|
|
18740
|
+
module.exports = import("./NewsContainer.05bb1b19.js").then(()=>parcelRequire('dUXW6'));
|
|
18778
18741
|
|
|
18779
18742
|
});
|
|
18780
18743
|
|
|
@@ -22427,7 +22390,6 @@ const $74b038ce1f8fa939$export$6108075486421829 = ()=>{
|
|
|
22427
22390
|
|
|
22428
22391
|
|
|
22429
22392
|
|
|
22430
|
-
|
|
22431
22393
|
var $1x02c = parcelRequire("1x02c");
|
|
22432
22394
|
|
|
22433
22395
|
var $aNpqK = parcelRequire("aNpqK");
|
|
@@ -22436,6 +22398,8 @@ var $9GPj7 = parcelRequire("9GPj7");
|
|
|
22436
22398
|
|
|
22437
22399
|
var $cT90l = parcelRequire("cT90l");
|
|
22438
22400
|
|
|
22401
|
+
var $4ucVo = parcelRequire("4ucVo");
|
|
22402
|
+
|
|
22439
22403
|
var $iT1WI = parcelRequire("iT1WI");
|
|
22440
22404
|
const $4551c1f557108aed$var$TelemetryContextDefaultValues = {
|
|
22441
22405
|
enabled: true,
|
|
@@ -22449,19 +22413,41 @@ function $4551c1f557108aed$export$a15d15518a3ec33d() {
|
|
|
22449
22413
|
}
|
|
22450
22414
|
function $4551c1f557108aed$export$bb3ea6dd2428edb6({ enabled: enabled, children: children }) {
|
|
22451
22415
|
const userId = (0, $aNpqK.useDirectlineStore)((state)=>state.userId);
|
|
22416
|
+
const conversationId = (0, $9GPj7.useActivityStore)((state)=>state.conversationId);
|
|
22452
22417
|
const addressData = (0, $1x02c.useRetorikStore)((state)=>state.addressData);
|
|
22453
22418
|
const lastActivity = (0, $9GPj7.useActivityStore)((state)=>state.lastActivity);
|
|
22454
22419
|
const botStreamingActivities = (0, $9GPj7.useActivityStore)((state)=>state.botStreamingActivities);
|
|
22455
|
-
const
|
|
22420
|
+
const lastUserActivityRef = (0, $bZRJW$useRef)(null);
|
|
22456
22421
|
const tracer = (0, $bZRJW$useMemo)(()=>{
|
|
22457
|
-
if (enabled && userId) {
|
|
22422
|
+
if (enabled && userId && conversationId) {
|
|
22458
22423
|
const exporter = new (0, $bZRJW$OTLPTraceExporter)({
|
|
22459
22424
|
url: (0, $cT90l.telemetryAddress),
|
|
22460
22425
|
headers: {},
|
|
22461
22426
|
concurrencyLimit: 1
|
|
22462
22427
|
});
|
|
22428
|
+
let serviceNamespace = '';
|
|
22429
|
+
switch(addressData.prefix){
|
|
22430
|
+
case 'dev':
|
|
22431
|
+
serviceNamespace = 'retorik-dev';
|
|
22432
|
+
break;
|
|
22433
|
+
case 'staging':
|
|
22434
|
+
case 'preview':
|
|
22435
|
+
serviceNamespace = 'retorik-preview';
|
|
22436
|
+
break;
|
|
22437
|
+
case 'experimental':
|
|
22438
|
+
serviceNamespace = 'retorik-experimental';
|
|
22439
|
+
break;
|
|
22440
|
+
default:
|
|
22441
|
+
serviceNamespace = 'retorik-prod';
|
|
22442
|
+
break;
|
|
22443
|
+
}
|
|
22444
|
+
// Create resource with custom parameters used globally in uptrace
|
|
22463
22445
|
const resource = (0, $bZRJW$defaultResource)().merge((0, $bZRJW$resourceFromAttributes)({
|
|
22464
|
-
[(0, $bZRJW$ATTR_SERVICE_NAME)]: 'retorik-framework'
|
|
22446
|
+
[(0, $bZRJW$ATTR_SERVICE_NAME)]: 'retorik-framework',
|
|
22447
|
+
['davi_retorik_activity_conversation_id']: conversationId,
|
|
22448
|
+
['service_namespace']: serviceNamespace,
|
|
22449
|
+
['retorik_framework_version']: (0, $iT1WI.version),
|
|
22450
|
+
['user_id']: userId
|
|
22465
22451
|
}));
|
|
22466
22452
|
const processor = new (0, $bZRJW$BatchSpanProcessor)(exporter);
|
|
22467
22453
|
const provider = new (0, $bZRJW$WebTracerProvider)({
|
|
@@ -22474,28 +22460,8 @@ function $4551c1f557108aed$export$bb3ea6dd2428edb6({ enabled: enabled, children:
|
|
|
22474
22460
|
// Add common attributes to each span for better tracing
|
|
22475
22461
|
(0, $bZRJW$registerInstrumentations)({
|
|
22476
22462
|
instrumentations: [
|
|
22477
|
-
new (0, $bZRJW$FetchInstrumentation)(
|
|
22478
|
-
|
|
22479
|
-
...getCommonAttributes(),
|
|
22480
|
-
user_id: userId
|
|
22481
|
-
})
|
|
22482
|
-
}),
|
|
22483
|
-
new (0, $bZRJW$DocumentLoadInstrumentation)({
|
|
22484
|
-
applyCustomAttributesOnSpan: {
|
|
22485
|
-
documentLoad: (span)=>span.setAttributes({
|
|
22486
|
-
...getCommonAttributes(),
|
|
22487
|
-
user_id: userId
|
|
22488
|
-
}),
|
|
22489
|
-
documentFetch: (span)=>span.setAttributes({
|
|
22490
|
-
...getCommonAttributes(),
|
|
22491
|
-
user_id: userId
|
|
22492
|
-
}),
|
|
22493
|
-
resourceFetch: (span)=>span.setAttributes({
|
|
22494
|
-
...getCommonAttributes(),
|
|
22495
|
-
user_id: userId
|
|
22496
|
-
})
|
|
22497
|
-
}
|
|
22498
|
-
})
|
|
22463
|
+
new (0, $bZRJW$FetchInstrumentation)(),
|
|
22464
|
+
new (0, $bZRJW$DocumentLoadInstrumentation)()
|
|
22499
22465
|
]
|
|
22500
22466
|
});
|
|
22501
22467
|
return (0, $bZRJW$opentelemetryapi).trace.getTracer('retorik-framework');
|
|
@@ -22503,7 +22469,10 @@ function $4551c1f557108aed$export$bb3ea6dd2428edb6({ enabled: enabled, children:
|
|
|
22503
22469
|
return undefined;
|
|
22504
22470
|
}, [
|
|
22505
22471
|
enabled,
|
|
22506
|
-
userId
|
|
22472
|
+
userId,
|
|
22473
|
+
conversationId,
|
|
22474
|
+
addressData,
|
|
22475
|
+
(0, $iT1WI.version)
|
|
22507
22476
|
]);
|
|
22508
22477
|
(0, $bZRJW$useEffect)(()=>{
|
|
22509
22478
|
if (lastActivity) lastActivity.from.role === 'user' ? handleUserActivity(lastActivity) : handleBotActivity(lastActivity);
|
|
@@ -22511,48 +22480,45 @@ function $4551c1f557108aed$export$bb3ea6dd2428edb6({ enabled: enabled, children:
|
|
|
22511
22480
|
lastActivity
|
|
22512
22481
|
]);
|
|
22513
22482
|
(0, $bZRJW$useEffect)(()=>{
|
|
22514
|
-
if (
|
|
22515
|
-
const temp = botStreamingActivities.get(
|
|
22483
|
+
if (lastUserActivityRef.current) {
|
|
22484
|
+
const temp = botStreamingActivities.get(lastUserActivityRef.current.id);
|
|
22516
22485
|
temp?.length === 1 && handleBotActivity(temp[0]);
|
|
22517
22486
|
}
|
|
22518
22487
|
}, [
|
|
22519
|
-
botStreamingActivities
|
|
22520
|
-
lastUserActivityData
|
|
22488
|
+
botStreamingActivities
|
|
22521
22489
|
]);
|
|
22522
|
-
const getCommonAttributes = ()=>{
|
|
22523
|
-
let tenant = '';
|
|
22524
|
-
if (addressData.tenant) tenant = addressData.prefix ? `${addressData.tenant} (${addressData.prefix})` : addressData.tenant;
|
|
22525
|
-
return {
|
|
22526
|
-
tenant: tenant,
|
|
22527
|
-
current_URL: window.location.toString(),
|
|
22528
|
-
os: `${0, $bZRJW$osName} ${0, $bZRJW$osVersion}`,
|
|
22529
|
-
browser: `${0, $bZRJW$browserName} ${0, $bZRJW$browserVersion}`,
|
|
22530
|
-
retorik_framework_version: (0, $iT1WI.version)
|
|
22531
|
-
};
|
|
22532
|
-
};
|
|
22533
22490
|
const handleUserActivity = (activity)=>{
|
|
22534
22491
|
// Only handle message activites and event activities waiting for an answer, nothing for typing ones
|
|
22535
|
-
if (activity.type === 'message' || activity.type === 'event' && !(0, $cT90l.nonResponseInducingEvents).find((eventName)=>activity.name?.toLowerCase().includes(eventName)))
|
|
22492
|
+
if (activity.type === 'message' || activity.type === 'event' && !(0, $cT90l.nonResponseInducingEvents).find((eventName)=>activity.name?.toLowerCase().includes(eventName))) lastUserActivityRef.current = {
|
|
22536
22493
|
id: activity.id,
|
|
22537
22494
|
time: Date.now()
|
|
22538
|
-
}
|
|
22495
|
+
};
|
|
22539
22496
|
};
|
|
22540
22497
|
const handleBotActivity = (activity)=>{
|
|
22541
22498
|
// Do nothing for bring-up messages and non-streaming events
|
|
22542
|
-
if (
|
|
22543
|
-
sendTrace(
|
|
22544
|
-
|
|
22499
|
+
if (lastUserActivityRef.current && (activity.type === 'message' || activity.name?.toLocaleLowerCase() === 'davi.streammessageactivity') && activity.label?.toLowerCase() !== 'davi.bringupmessage' && activity.replyToId === lastUserActivityRef.current.id) {
|
|
22500
|
+
sendTrace((0, $4ucVo.TraceType).message, lastUserActivityRef.current.time);
|
|
22501
|
+
lastUserActivityRef.current = null;
|
|
22545
22502
|
}
|
|
22546
22503
|
};
|
|
22547
|
-
const sendTrace = (
|
|
22548
|
-
if (tracer) {
|
|
22549
|
-
const
|
|
22550
|
-
|
|
22551
|
-
|
|
22504
|
+
const sendTrace = (type, data)=>{
|
|
22505
|
+
if (tracer && type) {
|
|
22506
|
+
const parameters = {};
|
|
22507
|
+
switch(type){
|
|
22508
|
+
case (0, $4ucVo.TraceType).message:
|
|
22509
|
+
parameters.startTime = data;
|
|
22510
|
+
break;
|
|
22511
|
+
case (0, $4ucVo.TraceType).utteranceStart:
|
|
22512
|
+
parameters.text = data;
|
|
22513
|
+
break;
|
|
22514
|
+
case (0, $4ucVo.TraceType).utteranceEnd:
|
|
22515
|
+
parameters.text = data;
|
|
22516
|
+
break;
|
|
22517
|
+
}
|
|
22518
|
+
const span = tracer.startSpan(type, parameters);
|
|
22552
22519
|
span.setStatus({
|
|
22553
22520
|
code: (0, $bZRJW$SpanStatusCode).OK
|
|
22554
22521
|
});
|
|
22555
|
-
span.setAttributes(getCommonAttributes());
|
|
22556
22522
|
span.end();
|
|
22557
22523
|
}
|
|
22558
22524
|
};
|
|
@@ -22564,24 +22530,21 @@ function $4551c1f557108aed$export$bb3ea6dd2428edb6({ enabled: enabled, children:
|
|
|
22564
22530
|
code: (0, $bZRJW$SpanStatusCode).ERROR,
|
|
22565
22531
|
message: `${error.message}`
|
|
22566
22532
|
});
|
|
22567
|
-
span.setAttributes(getCommonAttributes());
|
|
22568
22533
|
span.end();
|
|
22569
22534
|
}
|
|
22570
22535
|
};
|
|
22571
22536
|
const value = (0, $bZRJW$useMemo)(()=>({
|
|
22572
22537
|
enabled: enabled,
|
|
22573
22538
|
tracer: tracer,
|
|
22574
|
-
|
|
22575
|
-
|
|
22539
|
+
sendTrace: sendTrace,
|
|
22540
|
+
sendErrorTrace: sendErrorTrace
|
|
22576
22541
|
}), [
|
|
22577
22542
|
enabled,
|
|
22578
22543
|
tracer
|
|
22579
22544
|
]);
|
|
22580
|
-
return /*#__PURE__*/ (0, $bZRJW$jsx)(
|
|
22581
|
-
|
|
22582
|
-
|
|
22583
|
-
children: children
|
|
22584
|
-
})
|
|
22545
|
+
return /*#__PURE__*/ (0, $bZRJW$jsx)($4551c1f557108aed$export$7b6b7bc4acb29126.Provider, {
|
|
22546
|
+
value: value,
|
|
22547
|
+
children: children
|
|
22585
22548
|
});
|
|
22586
22549
|
}
|
|
22587
22550
|
|
|
@@ -23948,11 +23911,19 @@ var $f39384d6255fe275$export$2e2bcd8739ae039 = $f39384d6255fe275$var$BotResponse
|
|
|
23948
23911
|
|
|
23949
23912
|
|
|
23950
23913
|
|
|
23914
|
+
|
|
23915
|
+
var $1x02c = parcelRequire("1x02c");
|
|
23951
23916
|
parcelRequire("SZcIF");
|
|
23952
23917
|
var $jwPbX = parcelRequire("jwPbX");
|
|
23953
23918
|
const $3ff23eb3a82e4cf7$var$RetorikLogo = ()=>{
|
|
23954
|
-
|
|
23955
|
-
|
|
23919
|
+
const isUsedOnBorne = (0, $1x02c.useRetorikStore)((state)=>state.configuration.isUsedOnBorne);
|
|
23920
|
+
return isUsedOnBorne ? /*#__PURE__*/ (0, $bZRJW$jsx)("div", {
|
|
23921
|
+
className: "rf-hidden large:rf-block rf-relative rf-z-[1] ltr:rf-col-start-1 rtl:rf-col-end-1 rf-col-span-full rf-row-start-12 rf-row-span-1 ltr:rf-self-end rtl:rf-self-start rf-justify-self-start",
|
|
23922
|
+
children: /*#__PURE__*/ (0, $bZRJW$jsx)((0, $jwPbX.default), {
|
|
23923
|
+
className: "ltr:rf-ml-4 rtl:rf-mr-4 rf-mb-4 rf-h-14"
|
|
23924
|
+
})
|
|
23925
|
+
}) : /*#__PURE__*/ (0, $bZRJW$jsx)("a", {
|
|
23926
|
+
href: "https://davi.ai",
|
|
23956
23927
|
title: "Retorik by Davi",
|
|
23957
23928
|
target: "_blank",
|
|
23958
23929
|
rel: "noreferrer",
|
|
@@ -24220,8 +24191,6 @@ var $1x02c = parcelRequire("1x02c");
|
|
|
24220
24191
|
|
|
24221
24192
|
var $9GPj7 = parcelRequire("9GPj7");
|
|
24222
24193
|
|
|
24223
|
-
var $i1rfm = parcelRequire("i1rfm");
|
|
24224
|
-
|
|
24225
24194
|
|
|
24226
24195
|
var $dklvz = parcelRequire("dklvz");
|
|
24227
24196
|
|
|
@@ -24337,8 +24306,6 @@ const $ec519e4becb3ec60$var$DisplayStandard = ({ currentQuestionId: currentQuest
|
|
|
24337
24306
|
const endedActivities = (0, $9GPj7.useActivityStore)((state)=>state.endedActivities);
|
|
24338
24307
|
const watermark = (0, $9GPj7.useActivityStore)((state)=>state.watermark);
|
|
24339
24308
|
const forceMobileView = (0, $1x02c.useRetorikStore)((state)=>state.configuration.forceMobileView);
|
|
24340
|
-
const cancel = (0, $i1rfm.useSpeechStore)((state)=>state.cancel);
|
|
24341
|
-
const addEndedActivity = (0, $9GPj7.useActivityStore)((state)=>state.actions.addEndedActivity);
|
|
24342
24309
|
const [displayData, setDisplayData] = (0, $bZRJW$useState)([]);
|
|
24343
24310
|
const [currentDisplayDataIndex, setCurrentDisplayDataIndex] = (0, $bZRJW$useState)(0);
|
|
24344
24311
|
const [ended, setEnded] = (0, $bZRJW$useState)(!activities.length || endedActivities.includes(activities[activities.length - 1]?.id));
|
|
@@ -24353,7 +24320,7 @@ const $ec519e4becb3ec60$var$DisplayStandard = ({ currentQuestionId: currentQuest
|
|
|
24353
24320
|
]);
|
|
24354
24321
|
(0, $bZRJW$useEffect)(()=>{
|
|
24355
24322
|
if (isWaitingForResponse) {
|
|
24356
|
-
// Create temporary activity with the id of the
|
|
24323
|
+
// Create temporary activity with the id of the next one to prevent re-renders, in order to display waiting dots
|
|
24357
24324
|
const nextActivityId = `${currentQuestionId.slice(0, currentQuestionId.length - watermark.toString().length)}${watermark.toString()}`;
|
|
24358
24325
|
const tempActivity = {
|
|
24359
24326
|
id: nextActivityId,
|
|
@@ -24368,36 +24335,14 @@ const $ec519e4becb3ec60$var$DisplayStandard = ({ currentQuestionId: currentQuest
|
|
|
24368
24335
|
activity: tempActivity,
|
|
24369
24336
|
type: (0, $4ucVo.DisplayDataTypes).text,
|
|
24370
24337
|
isWaitingDots: true,
|
|
24371
|
-
canBeEnded: true
|
|
24338
|
+
canBeEnded: true,
|
|
24339
|
+
isEnded: false
|
|
24372
24340
|
}
|
|
24373
24341
|
]);
|
|
24374
24342
|
}
|
|
24375
24343
|
}, [
|
|
24376
24344
|
isWaitingForResponse
|
|
24377
24345
|
]);
|
|
24378
|
-
(0, $bZRJW$useEffect)(()=>{
|
|
24379
|
-
if (cancel) {
|
|
24380
|
-
activities.forEach((activity)=>{
|
|
24381
|
-
addEndedActivity(activity.id);
|
|
24382
|
-
});
|
|
24383
|
-
displayData.forEach((data)=>{
|
|
24384
|
-
addEndedActivity(data.activity.id);
|
|
24385
|
-
});
|
|
24386
|
-
}
|
|
24387
|
-
}, [
|
|
24388
|
-
cancel
|
|
24389
|
-
]);
|
|
24390
|
-
(0, $bZRJW$useEffect)(()=>{
|
|
24391
|
-
// End all current activities on component unmount
|
|
24392
|
-
return ()=>{
|
|
24393
|
-
activitiesRef.current.forEach((activity)=>{
|
|
24394
|
-
addEndedActivity(activity.id);
|
|
24395
|
-
});
|
|
24396
|
-
displayDataRef.current.forEach((data)=>{
|
|
24397
|
-
addEndedActivity(data.activity.id);
|
|
24398
|
-
});
|
|
24399
|
-
};
|
|
24400
|
-
}, []);
|
|
24401
24346
|
(0, $bZRJW$useEffect)(()=>{
|
|
24402
24347
|
activitiesRef.current = [
|
|
24403
24348
|
...activities
|
|
@@ -24409,7 +24354,7 @@ const $ec519e4becb3ec60$var$DisplayStandard = ({ currentQuestionId: currentQuest
|
|
|
24409
24354
|
let streamingTexts = [];
|
|
24410
24355
|
activities.forEach((activity, index)=>{
|
|
24411
24356
|
let splitTextDataToAdd = [];
|
|
24412
|
-
// Check the attachments, special case if this is the message activity after streaming : show attachments if the first streaming
|
|
24357
|
+
// Check the attachments, special case if this is the message activity after streaming : show attachments if the first streaming activity didn't have any
|
|
24413
24358
|
let attachments = [];
|
|
24414
24359
|
if (activity.attachments?.length) {
|
|
24415
24360
|
if (activity.name?.toLowerCase() === 'davi.streammessageactivity') {
|
|
@@ -24418,14 +24363,16 @@ const $ec519e4becb3ec60$var$DisplayStandard = ({ currentQuestionId: currentQuest
|
|
|
24418
24363
|
{
|
|
24419
24364
|
type: (0, $4ucVo.DisplayDataTypes).attachment,
|
|
24420
24365
|
activity: activity,
|
|
24421
|
-
canBeEnded: true
|
|
24366
|
+
canBeEnded: true,
|
|
24367
|
+
isEnded: true
|
|
24422
24368
|
}
|
|
24423
24369
|
];
|
|
24424
24370
|
} else if (!(activity.value?.streamingCount && streamingActivityHasAttachment) && !(0, $161354704eee0a17$export$7c55936a30618336)(activity)) attachments = [
|
|
24425
24371
|
{
|
|
24426
24372
|
type: (0, $4ucVo.DisplayDataTypes).attachment,
|
|
24427
24373
|
activity: activity,
|
|
24428
|
-
canBeEnded: true
|
|
24374
|
+
canBeEnded: true,
|
|
24375
|
+
isEnded: true
|
|
24429
24376
|
}
|
|
24430
24377
|
];
|
|
24431
24378
|
}
|
|
@@ -24443,14 +24390,20 @@ const $ec519e4becb3ec60$var$DisplayStandard = ({ currentQuestionId: currentQuest
|
|
|
24443
24390
|
...currentFirstStreamingActivity,
|
|
24444
24391
|
htmlText: (0, $dklvz.processMarkdownAndSpeechMarkdown)(streamingTexts.join(''), false).htmlText
|
|
24445
24392
|
},
|
|
24446
|
-
canBeEnded: false
|
|
24393
|
+
canBeEnded: false,
|
|
24394
|
+
isEnded: false
|
|
24447
24395
|
}
|
|
24448
24396
|
];
|
|
24449
24397
|
}
|
|
24450
24398
|
} else if (activity.value?.streamingCount) {
|
|
24451
24399
|
if (tempDisplayData.length) {
|
|
24452
24400
|
const lastStreamingIndex = tempDisplayData.findLastIndex((d)=>d.type === (0, $4ucVo.DisplayDataTypes).text);
|
|
24453
|
-
lastStreamingIndex !== -1
|
|
24401
|
+
if (lastStreamingIndex !== -1) {
|
|
24402
|
+
// Set canBeEnded for the previous streaming
|
|
24403
|
+
tempDisplayData[lastStreamingIndex].canBeEnded = true;
|
|
24404
|
+
// Set previous streaming ended if this activity is ended in speech synthesis
|
|
24405
|
+
tempDisplayData[lastStreamingIndex].isEnded = endedActivities.includes(activity.id);
|
|
24406
|
+
}
|
|
24454
24407
|
}
|
|
24455
24408
|
// Reset streaming data if the message containing all streaming data is received
|
|
24456
24409
|
currentFirstStreamingActivity = undefined;
|
|
@@ -24465,7 +24418,8 @@ const $ec519e4becb3ec60$var$DisplayStandard = ({ currentQuestionId: currentQuest
|
|
|
24465
24418
|
{
|
|
24466
24419
|
type: (0, $4ucVo.DisplayDataTypes).text,
|
|
24467
24420
|
activity: activity,
|
|
24468
|
-
canBeEnded: true
|
|
24421
|
+
canBeEnded: true,
|
|
24422
|
+
isEnded: endedActivities.includes(activity.id)
|
|
24469
24423
|
}
|
|
24470
24424
|
];
|
|
24471
24425
|
}
|
|
@@ -24487,7 +24441,8 @@ const $ec519e4becb3ec60$var$DisplayStandard = ({ currentQuestionId: currentQuest
|
|
|
24487
24441
|
}
|
|
24488
24442
|
}, [
|
|
24489
24443
|
currentQuestionId,
|
|
24490
|
-
activities.length
|
|
24444
|
+
activities.length,
|
|
24445
|
+
endedActivities
|
|
24491
24446
|
]);
|
|
24492
24447
|
(0, $bZRJW$useEffect)(()=>{
|
|
24493
24448
|
displayDataRef.current = [
|
|
@@ -24510,7 +24465,6 @@ const $ec519e4becb3ec60$var$DisplayStandard = ({ currentQuestionId: currentQuest
|
|
|
24510
24465
|
ended
|
|
24511
24466
|
]);
|
|
24512
24467
|
const handleEnded = ()=>{
|
|
24513
|
-
addEndedActivity(displayData[currentDisplayDataIndex]?.activity?.id);
|
|
24514
24468
|
setCurrentDisplayDataIndex((current)=>current + 1);
|
|
24515
24469
|
!ended && triggerScroll();
|
|
24516
24470
|
};
|
|
@@ -24531,7 +24485,7 @@ const $ec519e4becb3ec60$var$DisplayStandard = ({ currentQuestionId: currentQuest
|
|
|
24531
24485
|
triggerScroll: triggerScroll,
|
|
24532
24486
|
onEnded: handleEnded,
|
|
24533
24487
|
canBeEnded: data.canBeEnded,
|
|
24534
|
-
isEnded: data.
|
|
24488
|
+
isEnded: data.isEnded,
|
|
24535
24489
|
isWaitingDots: data.isWaitingDots
|
|
24536
24490
|
}, `${data.activity.id}-${key}`);
|
|
24537
24491
|
}
|
|
@@ -25716,8 +25670,7 @@ const $52152cf5bb15b9c1$var$WarningBeforeNewsView = ()=>{
|
|
|
25716
25670
|
const sendEvent = (0, $aNpqK.useDirectlineStore)((state)=>state.actions.sendEvent);
|
|
25717
25671
|
const [waiting, setWaiting] = (0, $bZRJW$useState)(true);
|
|
25718
25672
|
const handleClick = (goHome)=>{
|
|
25719
|
-
sendEvent('Davi.CloseWindow', null);
|
|
25720
|
-
sendEvent('Davi.CloseWindowNewsSoundActivated', null);
|
|
25673
|
+
sendEvent('Davi.CloseWindow', null, ()=>sendEvent('Davi.CloseWindowNewsSoundActivated', null));
|
|
25721
25674
|
goHome ? setRoute((0, $4ucVo.Routes).Home) : setWaiting(false);
|
|
25722
25675
|
};
|
|
25723
25676
|
return waiting ? /*#__PURE__*/ (0, $bZRJW$jsxs)("div", {
|
|
@@ -26085,29 +26038,6 @@ var $1x02c = parcelRequire("1x02c");
|
|
|
26085
26038
|
var $aNpqK = parcelRequire("aNpqK");
|
|
26086
26039
|
|
|
26087
26040
|
var $4ucVo = parcelRequire("4ucVo");
|
|
26088
|
-
/* Return codes:
|
|
26089
|
-
0 => do nothing
|
|
26090
|
-
1 => add to queue
|
|
26091
|
-
2 => stop current activity + change to the one tested
|
|
26092
|
-
*/ const $98181c365642ebbf$var$checkLastbotActivity = (lastbotActivity, currentPlaying, currentReplyToId, queuedActivities, endedActivities)=>{
|
|
26093
|
-
// Check if the activity is the one currently being played
|
|
26094
|
-
if (lastbotActivity.id === currentPlaying.id) return 0;
|
|
26095
|
-
// Check if the activity has already been ended
|
|
26096
|
-
if (endedActivities.includes(lastbotActivity.id)) return 0;
|
|
26097
|
-
// Check if the activity has the same replyToId than the one currently being played
|
|
26098
|
-
if (lastbotActivity.replyToId === currentReplyToId) {
|
|
26099
|
-
// Check if the activity is already in the queue
|
|
26100
|
-
let count = 0;
|
|
26101
|
-
if (queuedActivities.length > 0) queuedActivities.forEach((activity)=>{
|
|
26102
|
-
if (activity.id === lastbotActivity.id) count++;
|
|
26103
|
-
});
|
|
26104
|
-
if (count === 0) return 1;
|
|
26105
|
-
else return 0;
|
|
26106
|
-
} else return 2;
|
|
26107
|
-
};
|
|
26108
|
-
var $98181c365642ebbf$export$2e2bcd8739ae039 = $98181c365642ebbf$var$checkLastbotActivity;
|
|
26109
|
-
|
|
26110
|
-
|
|
26111
26041
|
|
|
26112
26042
|
|
|
26113
26043
|
|
|
@@ -26699,7 +26629,8 @@ const $637384b103093c58$var$RetorikSpeech = ({ ponyfill: ponyfill, onEnd: onEnd,
|
|
|
26699
26629
|
const microphoneCloseAudioRef = (0, $bZRJW$useRef)(null);
|
|
26700
26630
|
const [DBReady, setDBReady] = (0, $bZRJW$useState)(false);
|
|
26701
26631
|
const [playingBlob, setPlayingBlob] = (0, $bZRJW$useState)(false);
|
|
26702
|
-
const
|
|
26632
|
+
const nextUtteranceDataRef = (0, $bZRJW$useRef)(null);
|
|
26633
|
+
const nextUtteranceTextRef = (0, $bZRJW$useRef)(null);
|
|
26703
26634
|
const nextUtteranceBoundariesRef = (0, $bZRJW$useRef)([]);
|
|
26704
26635
|
const nextUtteranceVisemesRef = (0, $bZRJW$useRef)([]);
|
|
26705
26636
|
const emptyTextUtteranceRef = (0, $bZRJW$useRef)(null);
|
|
@@ -26713,7 +26644,7 @@ const $637384b103093c58$var$RetorikSpeech = ({ ponyfill: ponyfill, onEnd: onEnd,
|
|
|
26713
26644
|
const stopCurrentPlaying = ()=>{
|
|
26714
26645
|
if (appAvailable || loaderClosed) {
|
|
26715
26646
|
// Cancel synthesis if using synthesizer
|
|
26716
|
-
if (!playingBlob) ponyfill
|
|
26647
|
+
if (!playingBlob) ponyfill.speechSynthesis.cancel();
|
|
26717
26648
|
resetNextUtteranceData();
|
|
26718
26649
|
if (audioRef.current && !audioRef.current?.paused) {
|
|
26719
26650
|
audioRef.current.pause();
|
|
@@ -26723,7 +26654,7 @@ const $637384b103093c58$var$RetorikSpeech = ({ ponyfill: ponyfill, onEnd: onEnd,
|
|
|
26723
26654
|
};
|
|
26724
26655
|
const attachEvents = (tempUtterance, isMainUtterance)=>{
|
|
26725
26656
|
tempUtterance.onerror = (event)=>{
|
|
26726
|
-
isMainUtterance ? handleError(event) :
|
|
26657
|
+
isMainUtterance ? handleError(event) : nextUtteranceDataRef.current = null;
|
|
26727
26658
|
};
|
|
26728
26659
|
tempUtterance.onsynthesiscompleted = ()=>{
|
|
26729
26660
|
const endBoundary = {
|
|
@@ -26790,29 +26721,33 @@ const $637384b103093c58$var$RetorikSpeech = ({ ponyfill: ponyfill, onEnd: onEnd,
|
|
|
26790
26721
|
return tempUtterance;
|
|
26791
26722
|
};
|
|
26792
26723
|
const processNextData = (data)=>{
|
|
26793
|
-
|
|
26794
|
-
|
|
26795
|
-
|
|
26796
|
-
|
|
26797
|
-
|
|
26724
|
+
nextUtteranceDataRef.current = data?.byteLength && nextUtteranceTextRef.current ? {
|
|
26725
|
+
text: nextUtteranceTextRef.current,
|
|
26726
|
+
data: {
|
|
26727
|
+
speechData: data,
|
|
26728
|
+
boundaries: nextUtteranceBoundariesRef.current,
|
|
26729
|
+
visemes: nextUtteranceVisemesRef.current
|
|
26730
|
+
}
|
|
26731
|
+
} : null;
|
|
26798
26732
|
// Reset boundary / viseme data
|
|
26799
26733
|
resetNextUtteranceData(true);
|
|
26800
26734
|
};
|
|
26801
26735
|
const resetNextUtteranceData = (keepArrayBufferData)=>{
|
|
26802
|
-
!keepArrayBufferData &&
|
|
26736
|
+
!keepArrayBufferData && (nextUtteranceDataRef.current = null);
|
|
26737
|
+
nextUtteranceTextRef.current = null;
|
|
26803
26738
|
nextUtteranceBoundariesRef.current = [];
|
|
26804
26739
|
nextUtteranceVisemesRef.current = [];
|
|
26805
26740
|
};
|
|
26806
26741
|
(0, $bZRJW$useEffect)(()=>{
|
|
26807
26742
|
if (utterance) {
|
|
26808
26743
|
if (utterance.text) {
|
|
26809
|
-
if (
|
|
26810
|
-
if (
|
|
26811
|
-
boundaryRef.current =
|
|
26812
|
-
setBoundaryData(
|
|
26813
|
-
setVisemeData(
|
|
26814
|
-
processData(
|
|
26815
|
-
} else // Play utterance whether by asking for a speech synthesis, or by retrieving data
|
|
26744
|
+
if (audioRef?.current) {
|
|
26745
|
+
if (nextUtteranceDataRef.current?.text === utterance.text && nextUtteranceDataRef.current.data) {
|
|
26746
|
+
boundaryRef.current = nextUtteranceDataRef.current.data.boundaries;
|
|
26747
|
+
setBoundaryData(nextUtteranceDataRef.current.data.boundaries);
|
|
26748
|
+
setVisemeData(nextUtteranceDataRef.current.data.visemes);
|
|
26749
|
+
processData(nextUtteranceDataRef.current.data.speechData, true);
|
|
26750
|
+
} else // Play utterance whether by asking for a speech synthesis, or by retrieving data from indexedDB
|
|
26816
26751
|
playUtterance(attachEvents(utterance, true));
|
|
26817
26752
|
} else stopCurrentPlaying();
|
|
26818
26753
|
} else handleEmptyTextUtterance();
|
|
@@ -26821,8 +26756,10 @@ const $637384b103093c58$var$RetorikSpeech = ({ ponyfill: ponyfill, onEnd: onEnd,
|
|
|
26821
26756
|
utterance
|
|
26822
26757
|
]);
|
|
26823
26758
|
(0, $bZRJW$useEffect)(()=>{
|
|
26824
|
-
|
|
26759
|
+
// If there are data in nextUtteranceTextRef, this means the previous synthesis data retrieval is not finished, so we don't begin a new one
|
|
26760
|
+
if (nextUtterance?.text && !nextUtteranceTextRef.current) {
|
|
26825
26761
|
const tempUtterance = attachEvents(nextUtterance);
|
|
26762
|
+
nextUtteranceTextRef.current = nextUtterance.text;
|
|
26826
26763
|
ponyfill.speechSynthesis.synthesizeAndGetArrayData(tempUtterance, processNextData);
|
|
26827
26764
|
} else resetNextUtteranceData();
|
|
26828
26765
|
}, [
|
|
@@ -26830,14 +26767,14 @@ const $637384b103093c58$var$RetorikSpeech = ({ ponyfill: ponyfill, onEnd: onEnd,
|
|
|
26830
26767
|
]);
|
|
26831
26768
|
const playUtterance = async (utt)=>{
|
|
26832
26769
|
if (DBReady && enableSpeechCaching !== false && utt) {
|
|
26833
|
-
const dataFromIndexedDB = await $637384b103093c58$var$DBManager.getSpeechData(`${locale}.${voice?.name}.${utt.text.replace($637384b103093c58$var$tagsRemoverRegex, '')
|
|
26770
|
+
const dataFromIndexedDB = await $637384b103093c58$var$DBManager.getSpeechData(`${locale}.${voice?.name}.${utt.text.replace($637384b103093c58$var$tagsRemoverRegex, '')}`);
|
|
26834
26771
|
if (dataFromIndexedDB) {
|
|
26835
26772
|
boundaryRef.current = dataFromIndexedDB.boundaries;
|
|
26836
26773
|
setBoundaryData(dataFromIndexedDB.boundaries);
|
|
26837
26774
|
setVisemeData(dataFromIndexedDB.visemes || []);
|
|
26838
26775
|
processData(dataFromIndexedDB.value, true);
|
|
26839
|
-
} else ponyfill
|
|
26840
|
-
} else ponyfill
|
|
26776
|
+
} else ponyfill.speechSynthesis.synthesizeAndGetArrayData(utt, processData);
|
|
26777
|
+
} else ponyfill.speechSynthesis.synthesizeAndGetArrayData(utt, processData);
|
|
26841
26778
|
};
|
|
26842
26779
|
const processData = (data, alreadyExistsInDB)=>{
|
|
26843
26780
|
if (data?.byteLength) {
|
|
@@ -26847,7 +26784,7 @@ const $637384b103093c58$var$RetorikSpeech = ({ ponyfill: ponyfill, onEnd: onEnd,
|
|
|
26847
26784
|
type: 'audio/mp3'
|
|
26848
26785
|
});
|
|
26849
26786
|
enableSpeechCaching !== false && !alreadyExistsInDB && DBReady && boundaryRef?.current && utterance && $637384b103093c58$var$DBManager.addSpeechData({
|
|
26850
|
-
id: `${locale}.${voice?.name}.${utterance.text.replace($637384b103093c58$var$tagsRemoverRegex, '')
|
|
26787
|
+
id: `${locale}.${voice?.name}.${utterance.text.replace($637384b103093c58$var$tagsRemoverRegex, '')}`,
|
|
26851
26788
|
value: data,
|
|
26852
26789
|
boundaries: boundaryRef.current,
|
|
26853
26790
|
visemes: visemeRef.current || []
|
|
@@ -26872,13 +26809,13 @@ const $637384b103093c58$var$RetorikSpeech = ({ ponyfill: ponyfill, onEnd: onEnd,
|
|
|
26872
26809
|
};
|
|
26873
26810
|
const handleEnd = ()=>{
|
|
26874
26811
|
if (appAvailable || loaderClosed) {
|
|
26875
|
-
onEnd
|
|
26812
|
+
onEnd?.();
|
|
26876
26813
|
resetData();
|
|
26877
26814
|
} else setLoaderClosed(true);
|
|
26878
26815
|
};
|
|
26879
26816
|
const handleError = (error)=>{
|
|
26880
|
-
console.log('
|
|
26881
|
-
onError
|
|
26817
|
+
console.log('Retorik Framework > speech synthesis error ', error);
|
|
26818
|
+
onError?.();
|
|
26882
26819
|
resetData();
|
|
26883
26820
|
};
|
|
26884
26821
|
const handleEmptyTextUtterance = ()=>{
|
|
@@ -26893,7 +26830,7 @@ const $637384b103093c58$var$RetorikSpeech = ({ ponyfill: ponyfill, onEnd: onEnd,
|
|
|
26893
26830
|
* - play 1 second muted sound to prime audio output
|
|
26894
26831
|
* - MANDATORY FOR SAFARI IN VOCAL MODE
|
|
26895
26832
|
*/ const primeRetorikSpeech = ()=>{
|
|
26896
|
-
if (
|
|
26833
|
+
if (audioRef.current) {
|
|
26897
26834
|
audioRef.current.play().catch((e)=>console.warn(e));
|
|
26898
26835
|
speechRecognitionAudioRef?.current && speechRecognitionAudioRef.current.play().catch((e)=>console.warn(e));
|
|
26899
26836
|
// Send animation start event to secure animation not playing on safari if permissions are not sufficient
|
|
@@ -26903,13 +26840,6 @@ const $637384b103093c58$var$RetorikSpeech = ({ ponyfill: ponyfill, onEnd: onEnd,
|
|
|
26903
26840
|
/**
|
|
26904
26841
|
* Play sound on speech recognition activation if it isn't disabled in configuration
|
|
26905
26842
|
*/ (0, $bZRJW$useEffect)(()=>{
|
|
26906
|
-
// if (
|
|
26907
|
-
// !!speechRecognitionOptions?.enableActivationSound &&
|
|
26908
|
-
// activeRecognitionState === RecognitionState.Listening
|
|
26909
|
-
// ) {
|
|
26910
|
-
// speechRecognitionAudioRef?.current &&
|
|
26911
|
-
// speechRecognitionAudioRef.current.play().catch((e) => console.warn(e))
|
|
26912
|
-
// }
|
|
26913
26843
|
if (useOldRemote) {
|
|
26914
26844
|
if (!!speechRecognitionOptions?.enableActivationSound && activeRecognitionState === (0, $4ucVo.RecognitionState).Listening) speechRecognitionAudioRef?.current?.play().catch((e)=>console.warn(e));
|
|
26915
26845
|
} else if (!!speechRecognitionOptions?.enableActivationSound) switch(activeRecognitionState){
|
|
@@ -26966,11 +26896,7 @@ var $637384b103093c58$export$2e2bcd8739ae039 = $637384b103093c58$var$RetorikSpee
|
|
|
26966
26896
|
|
|
26967
26897
|
const $0b8e5d756ffed1ac$var$SynthesisManager = ({ ponyfill: ponyfill, isRetorikNews: isRetorikNews })=>{
|
|
26968
26898
|
const cancel = (0, $i1rfm.useSpeechStore)((state)=>state.cancel);
|
|
26969
|
-
const streamingReplyToId = (0, $i1rfm.useSpeechStore)((state)=>state.streamingReplyToId);
|
|
26970
26899
|
const streamingQueue = (0, $i1rfm.useSpeechStore)((state)=>state.streamingQueue);
|
|
26971
|
-
const currentPlaying = (0, $i1rfm.useSpeechStore)((state)=>state.currentPlaying);
|
|
26972
|
-
const currentReplyToId = (0, $i1rfm.useSpeechStore)((state)=>state.currentReplyToId);
|
|
26973
|
-
const endedActivities = (0, $i1rfm.useSpeechStore)((state)=>state.endedActivities);
|
|
26974
26900
|
const voice = (0, $i1rfm.useSpeechStore)((state)=>state.voice);
|
|
26975
26901
|
const customVoice = (0, $i1rfm.useSpeechStore)((state)=>state.customVoice);
|
|
26976
26902
|
const activeRecognitionState = (0, $i1rfm.useSpeechStore)((state)=>state.activeRecognitionState);
|
|
@@ -26983,24 +26909,17 @@ const $0b8e5d756ffed1ac$var$SynthesisManager = ({ ponyfill: ponyfill, isRetorikN
|
|
|
26983
26909
|
const appAvailable = (0, $1x02c.useRetorikStore)((state)=>state.appAvailable);
|
|
26984
26910
|
const preventExpectedInputHint = (0, $1x02c.useRetorikStore)((state)=>state.configuration.preventExpectedInputHint);
|
|
26985
26911
|
const speechSynthesisOptions = (0, $1x02c.useRetorikStore)((state)=>state.configuration.speechSynthesisOptions);
|
|
26986
|
-
const currentNewsActivity = (0, $j67YK.useUtilsStore)((state)=>state.currentNewsActivity);
|
|
26987
|
-
const lastBotActivity = (0, $9GPj7.useActivityStore)((state)=>state.lastBotMessageActivity);
|
|
26988
26912
|
const checkReplacementLocale = (0, $2fuDN.useLocaleStore)((state)=>state.actions.checkReplacementLocale);
|
|
26989
26913
|
const setRetorikNewsEnded = (0, $j67YK.useUtilsStore)((state)=>state.actions.setRetorikNewsEnded);
|
|
26990
|
-
const { resetCancelCurrentUtterance: resetCancelCurrentUtterance, setSpeaking: setSpeaking,
|
|
26914
|
+
const { setCurrentOrLastPlayedActivity: setCurrentOrLastPlayedActivity, resetCancelCurrentUtterance: resetCancelCurrentUtterance, setSpeaking: setSpeaking, setBoundaryData: setBoundaryData, removeFirstFromStreamingQueue: removeFirstFromStreamingQueue, killCurrentStreaming: killCurrentStreaming, askPermission: askPermission, toggleMicrophone: toggleMicrophone } = (0, $i1rfm.useSpeechStore)((state)=>state.actions);
|
|
26991
26915
|
const addEndedActivity = (0, $9GPj7.useActivityStore)((state)=>state.actions.addEndedActivity);
|
|
26992
26916
|
const dispatchMarkActivity = (0, $aNpqK.useDirectlineStore)((state)=>state.actions.dispatchMarkActivity);
|
|
26993
26917
|
const [utterance, setUtterance] = (0, $bZRJW$useState)(null);
|
|
26994
26918
|
const [nextUtterance, setNextUtterance] = (0, $bZRJW$useState)(null);
|
|
26995
|
-
const cancelRef = (0, $bZRJW$useRef)(false);
|
|
26996
|
-
const isSpeaking = (0, $bZRJW$useRef)(false);
|
|
26997
26919
|
const isNewsViewRef = (0, $bZRJW$useRef)(!!isRetorikNews);
|
|
26998
26920
|
const lastListTextPlayedRef = (0, $bZRJW$useRef)('');
|
|
26999
|
-
const
|
|
26921
|
+
const streamingQueueRef = (0, $bZRJW$useRef)([]);
|
|
27000
26922
|
const currentActivityRef = (0, $bZRJW$useRef)(null);
|
|
27001
|
-
const currentPlayingRef = (0, $bZRJW$useRef)(null);
|
|
27002
|
-
const tempCurrentStreamingRef = (0, $bZRJW$useRef)(null);
|
|
27003
|
-
const streamingRelatedMessageRef = (0, $bZRJW$useRef)(null);
|
|
27004
26923
|
/**
|
|
27005
26924
|
* Check activity locale in case of voice change during the speech, to keep the language defined in activity
|
|
27006
26925
|
* instead of switching languages between answers that are written in the same language
|
|
@@ -27027,17 +26946,20 @@ const $0b8e5d756ffed1ac$var$SynthesisManager = ({ ponyfill: ponyfill, isRetorikN
|
|
|
27027
26946
|
return (0, $66dccbb634d6ce27$export$f969af62bba9a48b)(params, speechSynthesisOptions?.sayAs);
|
|
27028
26947
|
};
|
|
27029
26948
|
const resetData = ()=>{
|
|
27030
|
-
|
|
27031
|
-
|
|
27032
|
-
|
|
27033
|
-
|
|
27034
|
-
|
|
26949
|
+
// Set all activities curretnly in the queue as ended
|
|
26950
|
+
streamingQueueRef.current?.forEach((activity)=>{
|
|
26951
|
+
addEndedActivity(activity.id);
|
|
26952
|
+
});
|
|
26953
|
+
streamingQueueRef.current = [];
|
|
26954
|
+
killCurrentStreaming();
|
|
26955
|
+
currentActivityRef.current = null;
|
|
27035
26956
|
setUtterance(null);
|
|
27036
26957
|
setNextUtterance(null);
|
|
27037
26958
|
resetCancelCurrentUtterance();
|
|
26959
|
+
setSpeaking(false);
|
|
26960
|
+
setBoundaryData([]);
|
|
27038
26961
|
};
|
|
27039
|
-
const checkReplacementLocaleAndGetUtterance = (activity, checkReplacement = true
|
|
27040
|
-
setCurrent && (currentActivityRef.current = activity);
|
|
26962
|
+
const checkReplacementLocaleAndGetUtterance = (activity, checkReplacement = true)=>{
|
|
27041
26963
|
const replacementLocale = checkReplacement ? checkReplacementLocale(activity.locale || locale) : locale;
|
|
27042
26964
|
const params = {
|
|
27043
26965
|
activity: activity,
|
|
@@ -27046,172 +26968,39 @@ const $0b8e5d756ffed1ac$var$SynthesisManager = ({ ponyfill: ponyfill, isRetorikN
|
|
|
27046
26968
|
};
|
|
27047
26969
|
return checkActivityAndCreateUtterance(params);
|
|
27048
26970
|
};
|
|
27049
|
-
|
|
26971
|
+
/**
|
|
26972
|
+
* Check if the microphone can be opened automatically
|
|
26973
|
+
*/ const checkDictateState = ()=>{
|
|
27050
26974
|
if (!preventExpectedInputHint && mode === (0, $4ucVo.Mode).vocal && activeRecognitionState === (0, $4ucVo.RecognitionState).Closed) {
|
|
27051
26975
|
if (!isMicrophoneAllowed) askPermission();
|
|
27052
26976
|
else toggleMicrophone(true);
|
|
27053
26977
|
}
|
|
27054
26978
|
};
|
|
27055
|
-
(0, $bZRJW$useEffect)(()=>{
|
|
27056
|
-
if (isNewsViewRef.current) {
|
|
27057
|
-
if (currentNewsActivity) {
|
|
27058
|
-
setUtterance(checkReplacementLocaleAndGetUtterance(currentNewsActivity));
|
|
27059
|
-
isSpeaking.current = true;
|
|
27060
|
-
} else {
|
|
27061
|
-
setUtterance(null);
|
|
27062
|
-
isSpeaking.current = false;
|
|
27063
|
-
}
|
|
27064
|
-
}
|
|
27065
|
-
}, [
|
|
27066
|
-
currentNewsActivity,
|
|
27067
|
-
ponyfill
|
|
27068
|
-
]);
|
|
27069
26979
|
/**
|
|
27070
|
-
* On
|
|
27071
|
-
* - when we toggle from a view to another, we reset the data related to speech
|
|
26980
|
+
* On route change, reset all data and check if we are on the news view
|
|
27072
26981
|
*/ (0, $bZRJW$useEffect)(()=>{
|
|
27073
|
-
setSpeaking(false);
|
|
27074
|
-
setBoundaryData([]);
|
|
27075
|
-
const ended = [
|
|
27076
|
-
...endedActivities
|
|
27077
|
-
];
|
|
27078
|
-
if (currentPlaying) {
|
|
27079
|
-
// Add played activity id to context's endedActivities
|
|
27080
|
-
ended.length > 10 && ended.splice(0, 1);
|
|
27081
|
-
if (currentPlaying.id) {
|
|
27082
|
-
ended.push(currentPlaying.id);
|
|
27083
|
-
addEndedActivity(currentPlaying.id);
|
|
27084
|
-
}
|
|
27085
|
-
setEndedActivities(ended);
|
|
27086
|
-
}
|
|
27087
|
-
setCurrentPlaying(undefined);
|
|
27088
26982
|
resetData();
|
|
27089
26983
|
if (!isRetorikNews) isNewsViewRef.current = route === (0, $4ucVo.Routes).News;
|
|
27090
26984
|
}, [
|
|
27091
26985
|
route
|
|
27092
26986
|
]);
|
|
27093
26987
|
/**
|
|
27094
|
-
* On
|
|
27095
|
-
* - appAvailable is set to true after the user interacted with the loader and every needed element is loaded
|
|
27096
|
-
* - no utterance is created while appAvailable isn't true
|
|
27097
|
-
* - if during the waiting time, some activities were queued, when appAvailable comes to true, let's begin creating the utterances and playing them
|
|
27098
|
-
*/ (0, $bZRJW$useEffect)(()=>{
|
|
27099
|
-
if (appAvailable && queuedActivitiesRef.current?.length) {
|
|
27100
|
-
setUtterance(checkReplacementLocaleAndGetUtterance(queuedActivitiesRef.current[0]));
|
|
27101
|
-
queuedActivitiesRef.current.splice(0, 1);
|
|
27102
|
-
isSpeaking.current = true;
|
|
27103
|
-
}
|
|
27104
|
-
}, [
|
|
27105
|
-
appAvailable
|
|
27106
|
-
]);
|
|
27107
|
-
/**
|
|
27108
|
-
* On speechCancelStore's cancel state change :
|
|
27109
|
-
* - if there is currently no utterance being played, reset cancel state to false
|
|
27110
|
-
* - if an utterance is being played, set it to null to stop playing and prevent data in queue from being played
|
|
27111
|
-
* - setting an utterance to null will trigger the handleUtteranceEnded method automatically
|
|
26988
|
+
* On cancel call, reset all data and kill current streaming
|
|
27112
26989
|
*/ (0, $bZRJW$useEffect)(()=>{
|
|
27113
|
-
|
|
27114
|
-
if (cancel) {
|
|
27115
|
-
utterance ? setUtterance(null) : resetCancelCurrentUtterance();
|
|
27116
|
-
isSpeaking.current = false;
|
|
27117
|
-
setNextUtterance(null);
|
|
27118
|
-
killCurrentStreaming();
|
|
27119
|
-
}
|
|
26990
|
+
cancel && resetData();
|
|
27120
26991
|
}, [
|
|
27121
26992
|
cancel
|
|
27122
26993
|
]);
|
|
27123
26994
|
/**
|
|
27124
|
-
*
|
|
27125
|
-
* - if the activity doesn't have a replyToId value, put it in the queue (used for reminder process)
|
|
27126
|
-
* - if the app is not available yet, put the activity in the queue if it is not yet inside
|
|
27127
|
-
* - NB: an activity can be received once from the directline, but can be found several times in the activities in the botframework
|
|
27128
|
-
* this is because it is processed multiple times if there is something to speak (channelDate empty, then channelData with {speak: true})
|
|
27129
|
-
* - if an utterance is being played, process the new one (do nothing / put it in the queue / stop the current one and play the new one)
|
|
27130
|
-
* - if an utterance has to be created, create it and set the utterance state
|
|
26995
|
+
* Play external speech immediately but don't add it to the history
|
|
27131
26996
|
*/ (0, $bZRJW$useEffect)(()=>{
|
|
27132
|
-
if (voice && lastBotActivity?.id) {
|
|
27133
|
-
let createNewUtterance = false;
|
|
27134
|
-
if (!lastBotActivity.replyToId) {
|
|
27135
|
-
if (isNewsViewRef.current) ;
|
|
27136
|
-
else if (currentPlaying || queuedActivitiesRef.current?.length) queuedActivitiesRef.current = [
|
|
27137
|
-
...queuedActivitiesRef.current,
|
|
27138
|
-
lastBotActivity
|
|
27139
|
-
];
|
|
27140
|
-
else if (endedActivities.length === 0 || endedActivities[endedActivities.length - 1] !== lastBotActivity.id) createNewUtterance = true;
|
|
27141
|
-
} else if (lastBotActivity.replyToId === streamingReplyToId) {
|
|
27142
|
-
if (lastBotActivity.value?.streamingId) {
|
|
27143
|
-
setCurrentPlaying(lastBotActivity);
|
|
27144
|
-
currentPlayingRef.current = lastBotActivity;
|
|
27145
|
-
// Keep the message related to playing streaming activities to deal with when streaming is ended
|
|
27146
|
-
streamingRelatedMessageRef.current = lastBotActivity;
|
|
27147
|
-
} else queuedActivitiesRef.current = [
|
|
27148
|
-
...queuedActivitiesRef.current,
|
|
27149
|
-
lastBotActivity
|
|
27150
|
-
];
|
|
27151
|
-
} else if (!appAvailable) {
|
|
27152
|
-
if (!currentReplyToId) {
|
|
27153
|
-
setCurrentReplyToId(lastBotActivity.replyToId);
|
|
27154
|
-
queuedActivitiesRef.current = [
|
|
27155
|
-
lastBotActivity
|
|
27156
|
-
];
|
|
27157
|
-
} else {
|
|
27158
|
-
if (currentReplyToId === lastBotActivity.replyToId) {
|
|
27159
|
-
if (!queuedActivitiesRef.current?.find((act)=>act.id === lastBotActivity.id)) queuedActivitiesRef.current = [
|
|
27160
|
-
...queuedActivitiesRef.current,
|
|
27161
|
-
lastBotActivity
|
|
27162
|
-
];
|
|
27163
|
-
} else {
|
|
27164
|
-
setCurrentReplyToId(lastBotActivity.replyToId);
|
|
27165
|
-
queuedActivitiesRef.current = [
|
|
27166
|
-
lastBotActivity
|
|
27167
|
-
];
|
|
27168
|
-
}
|
|
27169
|
-
}
|
|
27170
|
-
} else if (currentActivityRef?.current) switch((0, $98181c365642ebbf$export$2e2bcd8739ae039)(lastBotActivity, currentActivityRef.current, currentReplyToId, queuedActivitiesRef.current, endedActivities)){
|
|
27171
|
-
case 0:
|
|
27172
|
-
break;
|
|
27173
|
-
case 1:
|
|
27174
|
-
// Add the activity to the queue
|
|
27175
|
-
queuedActivitiesRef.current.push(lastBotActivity);
|
|
27176
|
-
break;
|
|
27177
|
-
case 2:
|
|
27178
|
-
// Stop current activity and play the new one
|
|
27179
|
-
queuedActivitiesRef.current = [];
|
|
27180
|
-
createNewUtterance = true;
|
|
27181
|
-
break;
|
|
27182
|
-
}
|
|
27183
|
-
else createNewUtterance = !endedActivities.includes(lastBotActivity.id);
|
|
27184
|
-
if (createNewUtterance) {
|
|
27185
|
-
setCurrentReplyToId(lastBotActivity.replyToId || 'customReplyToIdIfNotPresent');
|
|
27186
|
-
setUtterance(checkReplacementLocaleAndGetUtterance(lastBotActivity));
|
|
27187
|
-
isSpeaking.current = true;
|
|
27188
|
-
}
|
|
27189
|
-
}
|
|
27190
|
-
}, [
|
|
27191
|
-
lastBotActivity,
|
|
27192
|
-
ponyfill,
|
|
27193
|
-
voice
|
|
27194
|
-
]);
|
|
27195
|
-
(0, $bZRJW$useEffect)(()=>{
|
|
27196
|
-
if (streamingReplyToId && streamingQueue.length) {
|
|
27197
|
-
setUtterance(checkReplacementLocaleAndGetUtterance(streamingQueue[0], false, false));
|
|
27198
|
-
isSpeaking.current = true;
|
|
27199
|
-
setCurrentPlaying(undefined);
|
|
27200
|
-
currentPlayingRef.current = null;
|
|
27201
|
-
currentActivityRef.current = null;
|
|
27202
|
-
tempCurrentStreamingRef.current = streamingQueue[0].text || null;
|
|
27203
|
-
removeFirstFromStreamingQueue();
|
|
27204
|
-
}
|
|
27205
|
-
}, [
|
|
27206
|
-
streamingReplyToId
|
|
27207
|
-
]);
|
|
27208
|
-
(0, $bZRJW$useEffect)(()=>{
|
|
27209
26997
|
if (externalTextToSpeech) {
|
|
27210
|
-
|
|
26998
|
+
const activity = {
|
|
27211
26999
|
speak: externalTextToSpeech,
|
|
27212
27000
|
locale: locale
|
|
27213
|
-
}
|
|
27214
|
-
|
|
27001
|
+
};
|
|
27002
|
+
currentActivityRef.current = activity;
|
|
27003
|
+
setUtterance(checkReplacementLocaleAndGetUtterance(activity, false));
|
|
27215
27004
|
}
|
|
27216
27005
|
}, [
|
|
27217
27006
|
externalTextToSpeech
|
|
@@ -27221,92 +27010,75 @@ const $0b8e5d756ffed1ac$var$SynthesisManager = ({ ponyfill: ponyfill, isRetorikN
|
|
|
27221
27010
|
document.dispatchEvent(speechEvent);
|
|
27222
27011
|
};
|
|
27223
27012
|
/**
|
|
27224
|
-
*
|
|
27225
|
-
* - set speaking state to true
|
|
27226
|
-
* - clear timerref timeout
|
|
27227
|
-
* - set currentPlaying and currentReplyToId states after a small delay to prevent make sure that the display will happen after the speech has begun
|
|
27013
|
+
* Called when utterance's "start" event is fired
|
|
27228
27014
|
*/ const handleUtteranceStart = ()=>{
|
|
27229
27015
|
setSpeaking(true);
|
|
27230
27016
|
if (!isNewsViewRef.current && currentActivityRef?.current) {
|
|
27231
|
-
|
|
27232
|
-
currentPlayingRef.current = currentActivityRef.current;
|
|
27017
|
+
setCurrentOrLastPlayedActivity(currentActivityRef.current);
|
|
27233
27018
|
currentActivityRef.current.id && dispatchMarkActivity(currentActivityRef.current.id, true);
|
|
27234
27019
|
}
|
|
27235
27020
|
dispatchSpeechEvent(true);
|
|
27236
27021
|
// Set next utterance to prepare synthesis data in order to improve fluidity
|
|
27237
|
-
if (
|
|
27238
|
-
const
|
|
27239
|
-
|
|
27240
|
-
const tempUtterance = checkReplacementLocaleAndGetUtterance(streamingQueue[0], false, false);
|
|
27241
|
-
tempUtterance.text !== nextUtterance?.text ? setNextUtterance(tempUtterance) : setNextUtterance(null);
|
|
27242
|
-
} else setNextUtterance(null);
|
|
27022
|
+
if (streamingQueueRef.current.length && !streamingQueueRef.current[0].value?.streamingCount) {
|
|
27023
|
+
const utt = checkReplacementLocaleAndGetUtterance(streamingQueueRef.current[0], false);
|
|
27024
|
+
setNextUtterance((current)=>utt.text === current?.text ? null : utt);
|
|
27243
27025
|
} else setNextUtterance(null);
|
|
27244
|
-
setCurrentStreaming(tempCurrentStreamingRef?.current);
|
|
27245
27026
|
};
|
|
27246
|
-
|
|
27027
|
+
/**
|
|
27028
|
+
* Called when utterance's "end" event is fired
|
|
27029
|
+
*/ const handleUtteranceEnd = ()=>{
|
|
27247
27030
|
setSpeaking(false);
|
|
27248
27031
|
dispatchSpeechEvent(false);
|
|
27249
|
-
if (isNewsViewRef.current)
|
|
27250
|
-
|
|
27251
|
-
|
|
27032
|
+
if (isNewsViewRef.current) {
|
|
27033
|
+
setRetorikNewsEnded(true);
|
|
27034
|
+
currentActivityRef.current = null;
|
|
27035
|
+
} else handleEnded();
|
|
27252
27036
|
};
|
|
27253
|
-
|
|
27254
|
-
|
|
27255
|
-
|
|
27256
|
-
|
|
27257
|
-
|
|
27258
|
-
* - if this was the last activity of the queue, check if the microphone has to be opened automatically (inputHint = expectingInput)
|
|
27259
|
-
*/ const handleEnded = ()=>{
|
|
27260
|
-
let futureUtterance = null;
|
|
27261
|
-
if (currentPlayingRef?.current) // Add played activity id to context's endedActivities
|
|
27262
|
-
{
|
|
27263
|
-
if (currentPlayingRef.current.id) {
|
|
27264
|
-
addEndedActivity(currentPlayingRef.current.id);
|
|
27265
|
-
dispatchMarkActivity(currentPlayingRef.current.id, false);
|
|
27266
|
-
}
|
|
27037
|
+
const handleEnded = ()=>{
|
|
27038
|
+
// Add played activity id to context's endedActivities
|
|
27039
|
+
if (currentActivityRef.current?.id) {
|
|
27040
|
+
addEndedActivity(currentActivityRef.current.id);
|
|
27041
|
+
dispatchMarkActivity(currentActivityRef.current.id, false);
|
|
27267
27042
|
}
|
|
27268
|
-
|
|
27269
|
-
|
|
27270
|
-
|
|
27271
|
-
|
|
27272
|
-
|
|
27273
|
-
|
|
27274
|
-
|
|
27275
|
-
|
|
27276
|
-
|
|
27277
|
-
|
|
27278
|
-
|
|
27279
|
-
|
|
27280
|
-
|
|
27281
|
-
|
|
27043
|
+
if (streamingQueueRef.current?.length) {
|
|
27044
|
+
// Check if this is the message sent after streaming activities
|
|
27045
|
+
if (streamingQueueRef.current[0].value?.streamingCount) {
|
|
27046
|
+
addEndedActivity(streamingQueueRef.current[0].id);
|
|
27047
|
+
// If there is another activity after this message, play it. If not, let's check if the microphone should be opened
|
|
27048
|
+
if (streamingQueueRef.current?.length > 1) {
|
|
27049
|
+
const utt = checkReplacementLocaleAndGetUtterance(streamingQueueRef.current[1]);
|
|
27050
|
+
currentActivityRef.current = streamingQueueRef.current[1];
|
|
27051
|
+
setUtterance(utt);
|
|
27052
|
+
removeFirstFromStreamingQueue(true);
|
|
27053
|
+
} else {
|
|
27054
|
+
streamingQueueRef.current[0].inputHint === 'expectingInput' && checkDictateState();
|
|
27055
|
+
currentActivityRef.current = null;
|
|
27056
|
+
setUtterance(null);
|
|
27057
|
+
setNextUtterance(null);
|
|
27058
|
+
removeFirstFromStreamingQueue();
|
|
27282
27059
|
}
|
|
27283
|
-
} else
|
|
27284
|
-
|
|
27285
|
-
|
|
27286
|
-
|
|
27287
|
-
|
|
27288
|
-
}
|
|
27060
|
+
} else {
|
|
27061
|
+
const utt = checkReplacementLocaleAndGetUtterance(streamingQueueRef.current[0]);
|
|
27062
|
+
currentActivityRef.current = streamingQueueRef.current[0];
|
|
27063
|
+
setUtterance(utt);
|
|
27064
|
+
removeFirstFromStreamingQueue();
|
|
27065
|
+
}
|
|
27066
|
+
} else {
|
|
27067
|
+
currentActivityRef.current?.inputHint === 'expectingInput' && checkDictateState();
|
|
27068
|
+
currentActivityRef.current = null;
|
|
27069
|
+
setUtterance(null);
|
|
27070
|
+
setNextUtterance(null);
|
|
27289
27071
|
}
|
|
27290
|
-
currentPlayingRef.current = null;
|
|
27291
|
-
setUtterance(futureUtterance);
|
|
27292
|
-
isSpeaking.current = !!futureUtterance;
|
|
27293
27072
|
};
|
|
27294
27073
|
/**
|
|
27295
|
-
*
|
|
27074
|
+
* Wait for app loading and voice selection to begin playing speech
|
|
27296
27075
|
*/ (0, $bZRJW$useEffect)(()=>{
|
|
27297
|
-
|
|
27298
|
-
|
|
27299
|
-
|
|
27300
|
-
if (streamingQueue.length) {
|
|
27301
|
-
futureUtterance = checkReplacementLocaleAndGetUtterance(streamingQueue[0], false, false);
|
|
27302
|
-
tempCurrentStreamingRef.current = streamingQueue[0].text || null;
|
|
27303
|
-
removeFirstFromStreamingQueue();
|
|
27304
|
-
}
|
|
27305
|
-
currentPlayingRef.current = null;
|
|
27306
|
-
setUtterance(futureUtterance);
|
|
27307
|
-
isSpeaking.current = !!futureUtterance;
|
|
27308
|
-
}
|
|
27076
|
+
// Set ref from the state to use in events
|
|
27077
|
+
streamingQueueRef.current = streamingQueue;
|
|
27078
|
+
if (appAvailable && voice && streamingQueue.length && !currentActivityRef.current) handleEnded();
|
|
27309
27079
|
}, [
|
|
27080
|
+
appAvailable,
|
|
27081
|
+
voice,
|
|
27310
27082
|
streamingQueue
|
|
27311
27083
|
]);
|
|
27312
27084
|
return /*#__PURE__*/ (0, $bZRJW$jsx)((0, $637384b103093c58$export$2e2bcd8739ae039), {
|
|
@@ -27820,8 +27592,7 @@ const $9ab097b39dd0663e$var$typingTimer = 2000;
|
|
|
27820
27592
|
const $9ab097b39dd0663e$var$SendTypingIndicator = ({ isRetorikNews: isRetorikNews })=>{
|
|
27821
27593
|
const speaking = (0, $i1rfm.useSpeechStore)((state)=>state.speaking);
|
|
27822
27594
|
const streamingQueue = (0, $i1rfm.useSpeechStore)((state)=>state.streamingQueue);
|
|
27823
|
-
const
|
|
27824
|
-
const lastRecognitionInterim = (0, $i1rfm.useSpeechStore)((state)=>state.lastRecognitionInterim);
|
|
27595
|
+
const activeRecognitionState = (0, $i1rfm.useSpeechStore)((state)=>state.activeRecognitionState);
|
|
27825
27596
|
const route = (0, $1Qww3.useViewStore)((state)=>state.route);
|
|
27826
27597
|
const loaderClosed = (0, $1x02c.useRetorikStore)((state)=>state.loaderClosed);
|
|
27827
27598
|
const appAvailable = (0, $1x02c.useRetorikStore)((state)=>state.appAvailable);
|
|
@@ -27834,17 +27605,18 @@ const $9ab097b39dd0663e$var$SendTypingIndicator = ({ isRetorikNews: isRetorikNew
|
|
|
27834
27605
|
const sendTyping = (0, $aNpqK.useDirectlineStore)((state)=>state.actions.sendTyping);
|
|
27835
27606
|
const dataRef = (0, $bZRJW$useRef)(false);
|
|
27836
27607
|
(0, $bZRJW$useEffect)(()=>{
|
|
27608
|
+
// Don't send typing activity when we are receiving streaming events
|
|
27609
|
+
const isReceivingStreamingData = !!streamingQueue.length && !!streamingQueue.find((activity)=>activity.name?.toLowerCase() === 'davi.streammessageactivity') && !streamingQueue.find((activity)=>activity.value?.streamingCount);
|
|
27837
27610
|
dataRef.current = !isWaitingForResponse && // Don't send typing activity when we are receiving streaming events
|
|
27838
|
-
!
|
|
27611
|
+
!isReceivingStreamingData && (!loaderClosed || activeRecognitionState !== (0, $4ucVo.RecognitionState).Closed || userIsTyping || userIsSwiping || speaking || currentSubView !== (0, $4ucVo.CurrentSubView).none || route === (0, $4ucVo.Routes).News || retorikEvent === (0, $4ucVo.RetorikEvent).DetailViewOpen || listStatus === (0, $4ucVo.ListStatus).opened);
|
|
27839
27612
|
}, [
|
|
27840
27613
|
appAvailable,
|
|
27841
27614
|
loaderClosed,
|
|
27842
|
-
|
|
27615
|
+
activeRecognitionState,
|
|
27843
27616
|
userIsTyping,
|
|
27844
27617
|
userIsSwiping,
|
|
27845
27618
|
speaking,
|
|
27846
27619
|
streamingQueue,
|
|
27847
|
-
streamingQueueFullLength,
|
|
27848
27620
|
currentSubView,
|
|
27849
27621
|
route,
|
|
27850
27622
|
retorikEvent,
|