@alan-ai/alan-sdk-web 1.8.40 → 1.8.42

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/alan_lib.js CHANGED
@@ -846,7 +846,7 @@
846
846
 
847
847
  /// <reference types="../global" />
848
848
  (function (ns) {
849
- var alanButtonVersion = '1.8.40';
849
+ var alanButtonVersion = '1.8.42';
850
850
  if (window.alanBtn) {
851
851
  console.warn('Alan: the Alan Button source code has already added (v.' + alanButtonVersion + ')');
852
852
  }
@@ -1033,6 +1033,7 @@
1033
1033
  window.tutorProject.off('scripts', onScriptsCb);
1034
1034
  window.tutorProject.off('text', onTextCbInMicBtn);
1035
1035
  window.tutorProject.off('parsed', onParsedCbInMicBtn);
1036
+ alanAudio.off('command', onCommandCbInMicBtn);
1036
1037
  rootEl.innerHTML = '';
1037
1038
  btnInstance = null;
1038
1039
  if (!isTutorMode()) {
@@ -1955,6 +1956,7 @@
1955
1956
  window.tutorProject.on('scripts', onScriptsCb);
1956
1957
  window.tutorProject.on('text', onTextCbInMicBtn);
1957
1958
  window.tutorProject.on('parsed', onParsedCbInMicBtn);
1959
+ alanAudio.on('command', onCommandCbInMicBtn);
1958
1960
  //window.tutorProject.on('popup', onPopup);
1959
1961
  // console.info('BTN: tutorProject', options.key);
1960
1962
  }
@@ -2086,7 +2088,6 @@
2086
2088
  alanAudio.on('micFail', onMicFail);
2087
2089
  alanAudio.on('playStart', onPlayStart);
2088
2090
  alanAudio.on('playStop', onPlayStop);
2089
- alanAudio.on('command', onCommandCbInMicBtn);
2090
2091
  alanAudio.start(resolve);
2091
2092
  if (options.onMicStarted) {
2092
2093
  options.onMicStarted();
@@ -2522,8 +2523,6 @@
2522
2523
  alanAudio.off('micFail', onMicFail);
2523
2524
  alanAudio.off('playStart', onPlayStart);
2524
2525
  alanAudio.off('playStop', onPlayStop);
2525
- alanAudio.off('command', onCommandCbInMicBtn);
2526
- //alanAudio.off('popup', onPopup);
2527
2526
  hideRecognisedText();
2528
2527
  switchState(DEFAULT);
2529
2528
  isAlanActive = false;
@@ -2646,9 +2645,12 @@
2646
2645
  turnOffVoiceFn();
2647
2646
  }
2648
2647
  function onCommandCbInMicBtn(e) {
2648
+ var _a, _b;
2649
2649
  // console.info('BTN: onCommandCbInMicBtn', e, new Date());
2650
- if (options.onCommand) {
2651
- options.onCommand(e.data);
2650
+ if (isAlanActive || (!isAlanActive && ((_b = (_a = e.ctx) === null || _a === void 0 ? void 0 : _a.opts) === null || _b === void 0 ? void 0 : _b.force) === true)) {
2651
+ if (options.onCommand) {
2652
+ options.onCommand(e.data);
2653
+ }
2652
2654
  }
2653
2655
  if (isAlanActive) {
2654
2656
  switchState(LISTENING);