@davi-ai/retorik-framework 1.1.3 → 1.1.5

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.
@@ -557,7 +557,8 @@ const $04ce41b46d359821$var$initialState = {
557
557
  streamingQueueForText: [],
558
558
  currentStreaming: null,
559
559
  streamingQueueFullLength: 0,
560
- streamingReplyToIdToIgnore: null
560
+ streamingReplyToIdToIgnore: null,
561
+ speechRecognitionDynamicGrammars: []
561
562
  };
562
563
  const $04ce41b46d359821$export$f299240efcda25a2 = (0, $b3y7N$create)()(()=>{
563
564
  return $04ce41b46d359821$var$initialState;
@@ -744,6 +745,27 @@ const $04ce41b46d359821$export$e9ca045daeb00700 = (value, replyToId)=>{
744
745
  streamingQueueFullLength: value
745
746
  });
746
747
  };
748
+ const $04ce41b46d359821$export$ec8986cae5ae5c2 = (value)=>{
749
+ const currentGrammars = $04ce41b46d359821$export$f299240efcda25a2.getState().speechRecognitionDynamicGrammars;
750
+ // For each value, verifiy if it doesn't exist in the array yet
751
+ if (Array.isArray(value)) {
752
+ const valuesToAdd = [];
753
+ value.forEach((val)=>{
754
+ !currentGrammars.includes(val) && valuesToAdd.push(val);
755
+ });
756
+ valuesToAdd.length && $04ce41b46d359821$export$f299240efcda25a2.setState({
757
+ speechRecognitionDynamicGrammars: [
758
+ ...currentGrammars,
759
+ ...valuesToAdd
760
+ ]
761
+ });
762
+ } else !currentGrammars.includes(value) && $04ce41b46d359821$export$f299240efcda25a2.setState({
763
+ speechRecognitionDynamicGrammars: [
764
+ ...currentGrammars,
765
+ value
766
+ ]
767
+ });
768
+ };
747
769
  const $04ce41b46d359821$export$b6d2196a3ce412d8 = ()=>{
748
770
  $04ce41b46d359821$export$f299240efcda25a2.setState({
749
771
  ...$04ce41b46d359821$var$initialState
@@ -792,7 +814,8 @@ const $56b00880a398c953$var$initialState = {
792
814
  currentLayout: (0, $f5ca62954d1f1f5b$export$a31c5a03aaeee5f).agent,
793
815
  userAlreadySet: false,
794
816
  disableSound: false,
795
- isWaitingForResponse: false
817
+ isWaitingForResponse: false,
818
+ skipLoader: false
796
819
  };
797
820
  let $56b00880a398c953$var$timer = null;
798
821
  const $56b00880a398c953$export$bd22554f31e5f96f = (0, $b3y7N$create)()(()=>{
@@ -900,6 +923,11 @@ const $56b00880a398c953$export$b468e470fbb95f20 = (value)=>{
900
923
  });
901
924
  }
902
925
  };
926
+ const $56b00880a398c953$export$575f08cc5f3ecd43 = (value)=>{
927
+ $56b00880a398c953$export$bd22554f31e5f96f.setState({
928
+ skipLoader: value
929
+ });
930
+ };
903
931
  const $56b00880a398c953$export$cd85ac4858c7290c = ()=>{
904
932
  $56b00880a398c953$export$bd22554f31e5f96f.setState({
905
933
  ...$56b00880a398c953$var$initialState
@@ -2252,7 +2280,6 @@ const $9b100ac34d01a331$export$bb2ccecd43d76d90 = async (value)=>{
2252
2280
  (0, $56b00880a398c953$export$b468e470fbb95f20)(false);
2253
2281
  // Create speak field from the text one
2254
2282
  const processedText = (0, $2e5b8b358de6cd42$export$1b8fbc30fb87d9aa)(value.text, true);
2255
- value.text = processedText.text;
2256
2283
  value.speak = processedText.text;
2257
2284
  (0, $957e950ca3ff2781$export$a6540370871e3c67)(undefined);
2258
2285
  (0, $04ce41b46d359821$export$9a026d007e335fc0)(value);
@@ -2917,8 +2944,12 @@ const $b641028d2eac8925$var$dispatchActivity = (activity)=>{
2917
2944
  (0, $9b100ac34d01a331$export$bf77ccf2b7638432)(retorikActivity);
2918
2945
  break;
2919
2946
  case (0, $0aa35ed98889e60d$export$bbd16b9b30e132b3).INCOMING_ACTIVITY:
2920
- if (retorikActivity.type === "event") (0, $9b100ac34d01a331$export$bb2ccecd43d76d90)(retorikActivity);
2921
- else if (retorikActivity.type === "message") (0, $9b100ac34d01a331$export$2c98bb0c7fa688b3)(retorikActivity);
2947
+ if (!$b641028d2eac8925$var$checkIfHandlerAbortsActivity(legacyType, activity)) {
2948
+ // Add data for better speech recognition if therer are some
2949
+ if (retorikActivity.channelData?.speechRecognitionGrammars) (0, $04ce41b46d359821$export$ec8986cae5ae5c2)(retorikActivity.channelData?.speechRecognitionGrammars);
2950
+ if (retorikActivity.type === "event") (0, $9b100ac34d01a331$export$bb2ccecd43d76d90)(retorikActivity);
2951
+ else if (retorikActivity.type === "message") (0, $9b100ac34d01a331$export$2c98bb0c7fa688b3)(retorikActivity);
2952
+ }
2922
2953
  break;
2923
2954
  }
2924
2955
  // Send POST_ACTIVITY_FULFILLED if the legacy type is SEND_MESSAGE or SEND_EVENT
@@ -9999,10 +10030,22 @@ const $a8e0bc17b0fe6d93$var$List = ({ activity: activity, onClose: onClose })=>{
9999
10030
  const timerRef = (0, $b3y7N$useRef)(null);
10000
10031
  const divRef = (0, $b3y7N$useRef)(null);
10001
10032
  const [abortController, setAbortController] = (0, $b3y7N$useState)(null);
10002
- /**
10003
- * On call :
10004
- * - set ListContext's content state to undefined
10005
- */ const handleClose = ()=>{
10033
+ const handleOpen = ()=>{
10034
+ (0, $3426110875af99d0$export$324bf243c7501c4d)(true);
10035
+ api.start({
10036
+ from: {
10037
+ transform: "translateX(-100%)"
10038
+ },
10039
+ to: {
10040
+ transform: "translateX(0%)"
10041
+ },
10042
+ config: {
10043
+ duration: $a8e0bc17b0fe6d93$var$springEnterDuration,
10044
+ easing: (0, $b3y7N$easings).easeInBack
10045
+ }
10046
+ });
10047
+ };
10048
+ const handleClose = ()=>{
10006
10049
  (0, $3426110875af99d0$export$324bf243c7501c4d)(false);
10007
10050
  api.start({
10008
10051
  from: {
@@ -10026,14 +10069,14 @@ const $a8e0bc17b0fe6d93$var$List = ({ activity: activity, onClose: onClose })=>{
10026
10069
  }, $a8e0bc17b0fe6d93$var$springLeaveDuration);
10027
10070
  }
10028
10071
  };
10029
- /**
10030
- * On activity prop change :
10031
- * - check if the activity has already been displayed or not, using utilsStore's lastListActivity state
10032
- * - if the activity hasn't been displayed yet, set ListContext's content state with the activity
10033
- * On component unmount :
10034
- * - set utilsStore's lastListActivity state to the current activity's id
10035
- */ (0, $b3y7N$useEffect)(()=>{
10036
- activity && activity.id !== lastListActivity && setContent(activity);
10072
+ (0, $b3y7N$useEffect)(()=>{
10073
+ if (activity && activity.id !== lastListActivity) {
10074
+ setContent(activity);
10075
+ if (timerRef.current) {
10076
+ clearTimeout(timerRef.current);
10077
+ handleOpen();
10078
+ }
10079
+ }
10037
10080
  return ()=>{
10038
10081
  activity?.id && (0, $3426110875af99d0$export$e2194ce98b9711c9)(activity.id);
10039
10082
  };
@@ -10078,19 +10121,7 @@ const $a8e0bc17b0fe6d93$var$List = ({ activity: activity, onClose: onClose })=>{
10078
10121
  content
10079
10122
  ]);
10080
10123
  (0, $b3y7N$useEffect)(()=>{
10081
- (0, $3426110875af99d0$export$324bf243c7501c4d)(true);
10082
- api.start({
10083
- from: {
10084
- transform: "translateX(-100%)"
10085
- },
10086
- to: {
10087
- transform: "translateX(0%)"
10088
- },
10089
- config: {
10090
- duration: $a8e0bc17b0fe6d93$var$springEnterDuration,
10091
- easing: (0, $b3y7N$easings).easeInBack
10092
- }
10093
- });
10124
+ handleOpen();
10094
10125
  return ()=>{
10095
10126
  (0, $3426110875af99d0$export$324bf243c7501c4d)(false);
10096
10127
  timerRef?.current && clearTimeout(timerRef.current);
@@ -12947,7 +12978,7 @@ const $26692c14feff4dbf$export$6478e9f7582bd8fc = ()=>{
12947
12978
  children: [
12948
12979
  /*#__PURE__*/ (0, $b3y7N$jsxs)("div", {
12949
12980
  children: [
12950
- municipalPoliceNumber && municipalPoliceNumber.length > 0 && /*#__PURE__*/ (0, $b3y7N$jsxs)("p", {
12981
+ municipalPoliceNumber?.length && /*#__PURE__*/ (0, $b3y7N$jsxs)("p", {
12951
12982
  className: "rf-text-xl rf-py-2",
12952
12983
  children: [
12953
12984
  `${translation.emergency.citypolice} : `,
@@ -12981,7 +13012,7 @@ const $26692c14feff4dbf$export$6478e9f7582bd8fc = ()=>{
12981
13012
  }),
12982
13013
  /*#__PURE__*/ (0, $b3y7N$jsxs)("div", {
12983
13014
  children: [
12984
- localHospitalName && localHospitalName.length > 0 && /*#__PURE__*/ (0, $b3y7N$jsxs)("p", {
13015
+ localHospitalName?.length && /*#__PURE__*/ (0, $b3y7N$jsxs)("p", {
12985
13016
  className: "rf-text-xl rf-py-2",
12986
13017
  children: [
12987
13018
  `${translation.emergency.hospital} ${localHospitalName} : `,
@@ -12991,7 +13022,7 @@ const $26692c14feff4dbf$export$6478e9f7582bd8fc = ()=>{
12991
13022
  })
12992
13023
  ]
12993
13024
  }),
12994
- poisonControlNumber && poisonControlNumber.length > 0 && /*#__PURE__*/ (0, $b3y7N$jsxs)("p", {
13025
+ poisonControlNumber?.length && /*#__PURE__*/ (0, $b3y7N$jsxs)("p", {
12995
13026
  className: "rf-text-xl rf-py-2",
12996
13027
  children: [
12997
13028
  `${translation.emergency.poison} : `,
@@ -15263,7 +15294,7 @@ const $b5b059eebccf168a$var$ContextProvider = ({ skipLoader: skipLoader, mode: m
15263
15294
  mode
15264
15295
  ]);
15265
15296
  (0, $b3y7N$useEffect)(()=>{
15266
- (0, $56b00880a398c953$export$982d69b78a955aaf)(!!skipLoader);
15297
+ (0, $56b00880a398c953$export$575f08cc5f3ecd43)(!!skipLoader);
15267
15298
  }, [
15268
15299
  skipLoader
15269
15300
  ]);
@@ -15368,7 +15399,12 @@ const $1286c804208ea5de$export$6969335ea1e4e77c = (target, source)=>{
15368
15399
  const targetValue = target[key];
15369
15400
  const sourceValue = source[key];
15370
15401
  if (targetValue || targetValue === false) {
15371
- if (Array.isArray(targetValue) && Array.isArray(sourceValue)) source[key] = targetValue.concat(sourceValue);
15402
+ if (Array.isArray(targetValue) && Array.isArray(sourceValue)) source[key] = [
15403
+ ...new Set([
15404
+ ...targetValue,
15405
+ ...sourceValue
15406
+ ])
15407
+ ];
15372
15408
  else if (isObject(targetValue) && isObject(sourceValue)) source[key] = $1286c804208ea5de$export$6969335ea1e4e77c(targetValue, sourceValue);
15373
15409
  else source[key] = targetValue;
15374
15410
  }
@@ -15872,6 +15908,8 @@ const $fde3bdcd46120869$var$springEnterDuration = 500;
15872
15908
  const $fde3bdcd46120869$var$springLeaveDuration = 1000;
15873
15909
  const $fde3bdcd46120869$var$GdprAndLoader = ({ appAvailable: appAvailable, handleValidation: handleValidation })=>{
15874
15910
  const displayGDPR = (0, $3426110875af99d0$export$77e4cc5334565f28)((state)=>state.GDPRDisplay);
15911
+ const isUsedOnBorne = (0, $56b00880a398c953$export$bd22554f31e5f96f)((state)=>state.configuration.isUsedOnBorne);
15912
+ const skipLoader = (0, $56b00880a398c953$export$bd22554f31e5f96f)((state)=>state.skipLoader);
15875
15913
  const loaderClosed = (0, $56b00880a398c953$export$bd22554f31e5f96f)((state)=>state.loaderClosed);
15876
15914
  const hideRetorikLogo = (0, $56b00880a398c953$export$bd22554f31e5f96f)((state)=>state.configuration.hideRetorikLogo);
15877
15915
  const isMobile = (0, $957e950ca3ff2781$export$d13b2577cb75f2ad)((state)=>state.isMobile);
@@ -15887,6 +15925,15 @@ const $fde3bdcd46120869$var$GdprAndLoader = ({ appAvailable: appAvailable, handl
15887
15925
  opacity: 0
15888
15926
  }
15889
15927
  }));
15928
+ (0, $b3y7N$useEffect)(()=>{
15929
+ if (isUsedOnBorne || skipLoader) {
15930
+ (0, $3426110875af99d0$export$ff26692bd8e0fbbd)(false);
15931
+ handleValidation();
15932
+ }
15933
+ }, [
15934
+ isUsedOnBorne,
15935
+ skipLoader
15936
+ ]);
15890
15937
  (0, $b3y7N$useEffect)(()=>{
15891
15938
  api.start({
15892
15939
  from: {
@@ -15938,7 +15985,7 @@ const $fde3bdcd46120869$var$GdprAndLoader = ({ appAvailable: appAvailable, handl
15938
15985
  }, [
15939
15986
  container?.current
15940
15987
  ]);
15941
- return displayGDPR || !(appAvailable || loaderClosed) ? /*#__PURE__*/ (0, $b3y7N$jsxs)((0, $b3y7N$animated).div, {
15988
+ return isUsedOnBorne || skipLoader ? /*#__PURE__*/ (0, $b3y7N$jsx)((0, $b3y7N$react).Fragment, {}) : displayGDPR || !(appAvailable || loaderClosed) ? /*#__PURE__*/ (0, $b3y7N$jsxs)((0, $b3y7N$animated).div, {
15942
15989
  id: "retorik-GDPR-and-loader",
15943
15990
  className: `rf-absolute rf-z-modal rf-top-0 rf-left-0 rf-h-full rf-w-full rf-font-default
15944
15991
  ${textSize}`,
@@ -15972,7 +16019,6 @@ const $ba6bf0e283157133$var$RetorikSpeech = ({ ponyfill: ponyfill, onEnd: onEnd,
15972
16019
  const loaderClosed = (0, $56b00880a398c953$export$bd22554f31e5f96f)((state)=>state.loaderClosed);
15973
16020
  const enableSpeechCaching = (0, $56b00880a398c953$export$bd22554f31e5f96f)((state)=>state.configuration.enableSpeechCaching);
15974
16021
  const speechRecognitionOptions = (0, $56b00880a398c953$export$bd22554f31e5f96f)((state)=>state.configuration.speechRecognitionOptions);
15975
- const isUsedOnBorne = (0, $56b00880a398c953$export$bd22554f31e5f96f)((state)=>state.configuration.isUsedOnBorne);
15976
16022
  const voice = (0, $04ce41b46d359821$export$f299240efcda25a2)((state)=>state.voice);
15977
16023
  const muted = (0, $04ce41b46d359821$export$f299240efcda25a2)((state)=>state.muted);
15978
16024
  const activeRecognitionState = (0, $04ce41b46d359821$export$f299240efcda25a2)((state)=>state.activeRecognitionState);
@@ -16198,7 +16244,7 @@ const $ba6bf0e283157133$var$RetorikSpeech = ({ ponyfill: ponyfill, onEnd: onEnd,
16198
16244
  preload: "auto",
16199
16245
  muted: appAvailable || loaderClosed ? muted : true
16200
16246
  }),
16201
- !isUsedOnBorne && /*#__PURE__*/ (0, $b3y7N$jsx)((0, $fde3bdcd46120869$export$2e2bcd8739ae039), {
16247
+ /*#__PURE__*/ (0, $b3y7N$jsx)((0, $fde3bdcd46120869$export$2e2bcd8739ae039), {
16202
16248
  appAvailable: appAvailable,
16203
16249
  handleValidation: primeRetorikSpeech
16204
16250
  })
@@ -16657,7 +16703,7 @@ const $45f8218489149157$var$SynthesisManager = ({ isRetorikNews: isRetorikNews }
16657
16703
  currentPlayingRef.current = null;
16658
16704
  setUtterance(futureUtterance);
16659
16705
  };
16660
- return /*#__PURE__*/ (0, $b3y7N$jsx)((0, $ba6bf0e283157133$export$2e2bcd8739ae039), {
16706
+ return ponyfill ? /*#__PURE__*/ (0, $b3y7N$jsx)((0, $ba6bf0e283157133$export$2e2bcd8739ae039), {
16661
16707
  ponyfill: ponyfill,
16662
16708
  appAvailable: appAvailable,
16663
16709
  utterance: utterance,
@@ -16665,7 +16711,7 @@ const $45f8218489149157$var$SynthesisManager = ({ isRetorikNews: isRetorikNews }
16665
16711
  onStart: handleUtteranceStart,
16666
16712
  onError: handleUtteranceEnd,
16667
16713
  onEnd: handleUtteranceEnd
16668
- });
16714
+ }) : /*#__PURE__*/ (0, $b3y7N$jsx)((0, $b3y7N$react).Fragment, {});
16669
16715
  };
16670
16716
  var $45f8218489149157$export$2e2bcd8739ae039 = $45f8218489149157$var$SynthesisManager;
16671
16717
 
@@ -16691,6 +16737,7 @@ const $862dc1a8ff0214ad$var$RecognitionManager = ()=>{
16691
16737
  const useContinuousRecognition = (0, $04ce41b46d359821$export$f299240efcda25a2)((state)=>state.useContinuousRecognition);
16692
16738
  const activeRecognitionState = (0, $04ce41b46d359821$export$f299240efcda25a2)((state)=>state.activeRecognitionState);
16693
16739
  const lastRecognitionInterim = (0, $04ce41b46d359821$export$f299240efcda25a2)((state)=>state.lastRecognitionInterim);
16740
+ const speechRecognitionDynamicGrammars = (0, $04ce41b46d359821$export$f299240efcda25a2)((state)=>state.speechRecognitionDynamicGrammars);
16694
16741
  const route = (0, $957e950ca3ff2781$export$d13b2577cb75f2ad)((state)=>state.route);
16695
16742
  const [ponyfill, setPonyfill] = (0, $b3y7N$useState)(null);
16696
16743
  const isActiveModeRef = (0, $b3y7N$useRef)();
@@ -16769,10 +16816,14 @@ const $862dc1a8ff0214ad$var$RecognitionManager = ()=>{
16769
16816
  // Set grammar list
16770
16817
  const grammarList = new (0, $b3y7N$SpeechGrammarList)();
16771
16818
  grammarList.phrases = getCommonAndLocalizedGrammars();
16819
+ if (speechRecognitionDynamicGrammars.length) speechRecognitionDynamicGrammars.forEach((grammar)=>{
16820
+ !grammarList.phrases.includes(grammar) && grammarList.phrases.push(grammar);
16821
+ });
16772
16822
  ponyfill.speechRecognition.grammars = grammarList;
16773
16823
  }
16774
16824
  }, [
16775
- locale
16825
+ locale,
16826
+ speechRecognitionDynamicGrammars
16776
16827
  ]);
16777
16828
  /**
16778
16829
  * Abort recognition if we are not on the 'home' page
@@ -17044,6 +17095,7 @@ const $9ecfb2c3feeca9a7$var$SendTypingIndicator = ({ isRetorikNews: isRetorikNew
17044
17095
  const route = (0, $957e950ca3ff2781$export$d13b2577cb75f2ad)((state)=>state.route);
17045
17096
  const loaderClosed = (0, $56b00880a398c953$export$bd22554f31e5f96f)((state)=>state.loaderClosed);
17046
17097
  const appAvailable = (0, $56b00880a398c953$export$bd22554f31e5f96f)((state)=>state.appAvailable);
17098
+ const isWaitingForResponse = (0, $56b00880a398c953$export$bd22554f31e5f96f)((state)=>state.isWaitingForResponse);
17047
17099
  const currentSubView = (0, $3426110875af99d0$export$77e4cc5334565f28)((state)=>state.currentSubView);
17048
17100
  const listOpened = (0, $3426110875af99d0$export$77e4cc5334565f28)((state)=>state.listOpened);
17049
17101
  const retorikEvent = (0, $3426110875af99d0$export$77e4cc5334565f28)((state)=>state.retorikEvent);
@@ -17051,7 +17103,7 @@ const $9ecfb2c3feeca9a7$var$SendTypingIndicator = ({ isRetorikNews: isRetorikNew
17051
17103
  const userIsSwiping = (0, $3426110875af99d0$export$77e4cc5334565f28)((state)=>state.userIsSwiping);
17052
17104
  const dataRef = (0, $b3y7N$useRef)(false);
17053
17105
  (0, $b3y7N$useEffect)(()=>{
17054
- dataRef.current = !loaderClosed || lastRecognitionInterim !== "" || userIsTyping || userIsSwiping || speaking || currentSubView !== (0, $f5ca62954d1f1f5b$export$f05d0fed0593ead7).none || route === (0, $f5ca62954d1f1f5b$export$3565eb3d00ca5a74).News || retorikEvent === (0, $f5ca62954d1f1f5b$export$4f7cd669585dc69f).DetailViewOpen || listOpened;
17106
+ dataRef.current = !isWaitingForResponse && (!loaderClosed || lastRecognitionInterim !== "" || userIsTyping || userIsSwiping || speaking || currentSubView !== (0, $f5ca62954d1f1f5b$export$f05d0fed0593ead7).none || route === (0, $f5ca62954d1f1f5b$export$3565eb3d00ca5a74).News || retorikEvent === (0, $f5ca62954d1f1f5b$export$4f7cd669585dc69f).DetailViewOpen || listOpened);
17055
17107
  }, [
17056
17108
  appAvailable,
17057
17109
  loaderClosed,
@@ -17062,7 +17114,8 @@ const $9ecfb2c3feeca9a7$var$SendTypingIndicator = ({ isRetorikNews: isRetorikNew
17062
17114
  currentSubView,
17063
17115
  route,
17064
17116
  retorikEvent,
17065
- listOpened
17117
+ listOpened,
17118
+ isWaitingForResponse
17066
17119
  ]);
17067
17120
  const checkShouldSendTypingIndicator = ()=>{
17068
17121
  dataRef.current && !isRetorikNews && (0, $b641028d2eac8925$export$81487d3d3f61cca3)();