@gamelearn/arcade-components 1.18.0 → 1.18.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -73,12 +73,15 @@ var ComicComponent = function ComicComponent(_ref) {
73
73
  var _soundActions = _slicedToArray(soundActions, 1),
74
74
  play = _soundActions[0];
75
75
 
76
+ var slide = slides === null || slides === void 0 ? void 0 : slides[slideCount];
76
77
  var close = (0, _react.useCallback)(function () {
77
78
  emitEvent({
78
79
  type: 'success'
79
80
  });
80
81
  }, [emitEvent]);
81
82
  var goToNextSlide = (0, _react.useCallback)(function () {
83
+ setAudioFailed(false);
84
+
82
85
  if (slideCount + 1 < slides.length) {
83
86
  setTransition('slide-animation');
84
87
  setCount(slideCount + 1);
@@ -87,6 +90,8 @@ var ComicComponent = function ComicComponent(_ref) {
87
90
  }
88
91
  }, [close, slideCount, slides === null || slides === void 0 ? void 0 : slides.length]);
89
92
  var goToPreviousSlide = (0, _react.useCallback)(function () {
93
+ setAudioFailed(false);
94
+
90
95
  if (slideCount - 1 >= 0) {
91
96
  setTransition('slide-animation');
92
97
  setCount(slideCount - 1);
@@ -117,9 +122,7 @@ var ComicComponent = function ComicComponent(_ref) {
117
122
  setAudioFailed(true);
118
123
  },
119
124
  onFinish: function onFinish() {
120
- var _slides$slideCount5;
121
-
122
- if (automatic && (slides === null || slides === void 0 ? void 0 : (_slides$slideCount5 = slides[slideCount]) === null || _slides$slideCount5 === void 0 ? void 0 : _slides$slideCount5.audioType) !== 'none') {
125
+ if (automatic) {
123
126
  goToNextSlide();
124
127
  }
125
128
  }
@@ -128,8 +131,6 @@ var ComicComponent = function ComicComponent(_ref) {
128
131
  stopEkho();
129
132
  }, [slideCount, stopEkho]);
130
133
  (0, _react.useEffect)(function () {
131
- var slide = slides === null || slides === void 0 ? void 0 : slides[slideCount];
132
-
133
134
  if (automatic && ((slide === null || slide === void 0 ? void 0 : slide.audioType) === 'none' || audioFailed)) {
134
135
  var _slide$vignettes$, _slide$vignettes$$tex;
135
136
 
@@ -140,7 +141,7 @@ var ComicComponent = function ComicComponent(_ref) {
140
141
  return function () {
141
142
  stop();
142
143
  };
143
- }, [audioFailed, automatic, goToNextSlide, slideCount, slides, start, stop]);
144
+ }, [audioFailed, automatic, goToNextSlide, slide === null || slide === void 0 ? void 0 : slide.audioType, slide === null || slide === void 0 ? void 0 : slide.vignettes, start, stop]);
144
145
  if (!(slides !== null && slides !== void 0 && slides.length)) return null;
145
146
  return /*#__PURE__*/_react.default.createElement("div", {
146
147
  dir: (0, _LangIsRtl.default)() ? 'rtl' : 'auto',
@@ -289,9 +289,9 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
289
289
  };
290
290
 
291
291
  var autoplayCond = automatic && !isDecision;
292
- (0, _useEkho.default)({
292
+ var stopEkho = (0, _useEkho.default)({
293
293
  audioType: currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.audioType,
294
- voice: currentMessage !== null && currentMessage !== void 0 && currentMessage.text ? currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.voice : null,
294
+ voice: currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.voice,
295
295
  text: currentMessage === null || currentMessage === void 0 ? void 0 : currentMessage.text,
296
296
  audio: currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.audio,
297
297
  soundActions: soundActions,
@@ -304,7 +304,10 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
304
304
  handleClickNext();
305
305
  }
306
306
  }
307
- }); // Autoplay logic
307
+ });
308
+ (0, _react.useEffect)(function () {
309
+ stopEkho();
310
+ }, [currentLine, stopEkho]); // Autoplay logic
308
311
 
309
312
  (0, _react.useEffect)(function () {
310
313
  if (autoplayCond && ((currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.audioType) === 'none' || audioFailed)) {
@@ -224,7 +224,9 @@ var DialogComponent = function DialogComponent(_ref) {
224
224
  var finishConversation = (0, _react.useCallback)(function () {
225
225
  resetAnims();
226
226
  lastSet.current = true;
227
- setCurrentMessage({});
227
+ setCurrentMessage({
228
+ show: false
229
+ });
228
230
  resetCameraView();
229
231
  setTimeout(function () {
230
232
  changeLine(0);
@@ -249,7 +251,9 @@ var DialogComponent = function DialogComponent(_ref) {
249
251
  });
250
252
 
251
253
  if (destination >= 0) {
252
- setCurrentMessage({});
254
+ setCurrentMessage({
255
+ show: false
256
+ });
253
257
  changeLine(destination);
254
258
  } else {
255
259
  finishConversation();
@@ -262,7 +266,9 @@ var DialogComponent = function DialogComponent(_ref) {
262
266
  if (isBranched) {
263
267
  handleBranchDirection(false);
264
268
  } else if (lastLine && !(lastLine !== null && lastLine !== void 0 && lastLine.decision) || lastLine.type && !lastLine.type !== 'conversationalDecision') {
265
- setCurrentMessage({});
269
+ setCurrentMessage({
270
+ show: false
271
+ });
266
272
  changeLine(line - 1);
267
273
  }
268
274
  }, [handleBranchDirection, isBranched, lastLine, line]);
@@ -282,7 +288,9 @@ var DialogComponent = function DialogComponent(_ref) {
282
288
  if ((currentEdge === null || currentEdge === void 0 ? void 0 : currentEdge.fromId) === (currentEdge === null || currentEdge === void 0 ? void 0 : currentEdge.toId)) {
283
289
  reset();
284
290
  } else {
285
- setCurrentMessage({});
291
+ setCurrentMessage({
292
+ show: false
293
+ });
286
294
  changeLine(destinationEdge);
287
295
  }
288
296
  } else {
@@ -299,7 +307,9 @@ var DialogComponent = function DialogComponent(_ref) {
299
307
  handleBranchDirection();
300
308
  }
301
309
  } else if (line < lines.length - 1) {
302
- setCurrentMessage({});
310
+ setCurrentMessage({
311
+ show: false
312
+ });
303
313
  changeLine(line + 1);
304
314
  } else {
305
315
  finishConversation();
@@ -454,9 +464,10 @@ var DialogComponent = function DialogComponent(_ref) {
454
464
  var audio = Object.keys(currentLine.audio || {}).length;
455
465
  var voice = Object.keys(currentLine.voice || {}).length; // Sound logic
456
466
 
457
- (0, _useEkho.default)({
467
+ var stopEkho = (0, _useEkho.default)({
458
468
  audioType: currentLine === null || currentLine === void 0 ? void 0 : currentLine.audioType,
459
- voice: currentMessage !== null && currentMessage !== void 0 && currentMessage.text ? currentLine === null || currentLine === void 0 ? void 0 : currentLine.voice : null,
469
+ voice: currentLine === null || currentLine === void 0 ? void 0 : currentLine.voice,
470
+ started: currentMessage.show,
460
471
  text: currentMessage === null || currentMessage === void 0 ? void 0 : currentMessage.text,
461
472
  audio: currentLine === null || currentLine === void 0 ? void 0 : currentLine.audio,
462
473
  soundActions: soundActions,
@@ -469,7 +480,10 @@ var DialogComponent = function DialogComponent(_ref) {
469
480
  nextLine();
470
481
  }
471
482
  }
472
- }); // Autoplay logic
483
+ });
484
+ (0, _react.useEffect)(function () {
485
+ stopEkho();
486
+ }, [line, stopEkho]); // Autoplay logic
473
487
 
474
488
  (0, _react.useEffect)(function () {
475
489
  if (autoPlayCond && currentMessage.show && ((currentLine === null || currentLine === void 0 ? void 0 : currentLine.audioType) === 'none' || audioFailed)) {
@@ -33,6 +33,8 @@ var useEkho = function useEkho(_ref) {
33
33
  audioType = _ref.audioType,
34
34
  _ref$loop = _ref.loop,
35
35
  loop = _ref$loop === void 0 ? false : _ref$loop,
36
+ _ref$started = _ref.started,
37
+ started = _ref$started === void 0 ? true : _ref$started,
36
38
  audio = _ref.audio,
37
39
  soundActions = _ref.soundActions,
38
40
  emitEvent = _ref.emitEvent,
@@ -139,9 +141,7 @@ var useEkho = function useEkho(_ref) {
139
141
  break;
140
142
 
141
143
  case 7:
142
- if (!payload.voiceId) {
143
- onError();
144
- }
144
+ onError();
145
145
 
146
146
  case 8:
147
147
  case "end":
@@ -166,7 +166,7 @@ var useEkho = function useEkho(_ref) {
166
166
  }
167
167
  }, [noAudio, stopCurrentAudio]);
168
168
  (0, _react.useEffect)(function () {
169
- if (isMounted) {
169
+ if (isMounted && started) {
170
170
  if (audioType === 'voice' && voice !== null && voice !== void 0 && voice.id) {
171
171
  var voiceId = getVoice(voice);
172
172
  playSpeech({
@@ -179,7 +179,7 @@ var useEkho = function useEkho(_ref) {
179
179
  onError();
180
180
  }
181
181
  }
182
- }, [getVoice, playSpeech, isMounted, voice, text, audioType, audio === null || audio === void 0 ? void 0 : audio.url, audio, setCurrentPlaying, onError]);
182
+ }, [getVoice, playSpeech, isMounted, voice, text, audioType, audio === null || audio === void 0 ? void 0 : audio.url, audio, setCurrentPlaying, onError, started]);
183
183
  return stopCurrentAudio;
184
184
  };
185
185
 
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@gamelearn/arcade-components",
3
3
  "author": "Gamelearn",
4
4
  "license": "unlicense",
5
- "version": "1.18.0",
5
+ "version": "1.18.1",
6
6
  "main": "dist/index.js",
7
7
  "files": [
8
8
  "dist",