@gamelearn/arcade-components 2.2.5 → 2.2.8-hotfix

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.
@@ -124,6 +124,7 @@ var ComicComponent = function ComicComponent(_ref) {
124
124
  voice: slides === null || slides === void 0 ? void 0 : (_slides$slideCount2 = slides[slideCount]) === null || _slides$slideCount2 === void 0 ? void 0 : _slides$slideCount2.voice,
125
125
  text: slides === null || slides === void 0 ? void 0 : (_slides$slideCount3 = slides[slideCount]) === null || _slides$slideCount3 === void 0 ? void 0 : (_slides$slideCount3$v = _slides$slideCount3.vignettes[0].textData) === null || _slides$slideCount3$v === void 0 ? void 0 : _slides$slideCount3$v.text,
126
126
  audio: slides === null || slides === void 0 ? void 0 : (_slides$slideCount4 = slides[slideCount]) === null || _slides$slideCount4 === void 0 ? void 0 : _slides$slideCount4.audio,
127
+ slide: slideCount,
127
128
  started: started,
128
129
  soundActions: soundActions,
129
130
  emitEvent: emitEvent,
@@ -350,7 +350,7 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
350
350
 
351
351
  if (isBranched) {
352
352
  handleBranchDirection(false);
353
- } else if (currentLine > 0) {
353
+ } else if (!previousLineWasDecision()) {
354
354
  setCurrentLine(currentLine - 1);
355
355
  }
356
356
 
@@ -385,12 +385,15 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
385
385
  };
386
386
 
387
387
  var autoplayCond = automatic && !isDecision && !pause;
388
- var disableBackButton = currentLine === 0 || previousLineWasDecision();
388
+ var disableBackButton = (0, _react.useMemo)(function () {
389
+ return currentLine === 0 || previousLineWasDecision();
390
+ }, [currentLine, previousLineWasDecision]);
389
391
  (0, _useEkho.default)({
390
392
  audioType: currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.audioType,
391
393
  volume: currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.audioVolume,
392
394
  voice: currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.voice,
393
395
  started: started,
396
+ slide: currentLine,
394
397
  text: currentMessage === null || currentMessage === void 0 ? void 0 : currentMessage.text,
395
398
  audio: currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.audio,
396
399
  soundActions: soundActions,
@@ -227,8 +227,8 @@ var DialogComponent = function DialogComponent(_ref) {
227
227
  } // if there is no branching, the previous line is the previous one
228
228
 
229
229
 
230
- var lastL = lines[currentLineData - 1] ? lines[currentLineData - 1] : {};
231
- return currentLineData > 0 && (lastL === null || lastL === void 0 ? void 0 : lastL.decision);
230
+ var lastL = lines[line - 1] ? lines[line - 1] : {};
231
+ return line > 0 && (lastL === null || lastL === void 0 ? void 0 : lastL.decision);
232
232
  }, [currentLineData, isBranched, lines, lastNodeId, edges]);
233
233
  var getCurrentVisible = (0, _react.useCallback)(function (uid) {
234
234
  if (!uid) return null;
@@ -414,7 +414,7 @@ var DialogComponent = function DialogComponent(_ref) {
414
414
 
415
415
  if (isBranched) {
416
416
  handleBranchDirection(false);
417
- } else if (previousLineWasDecision()) {
417
+ } else if (!previousLineWasDecision()) {
418
418
  setCurrentMessage({
419
419
  show: false
420
420
  });
@@ -638,6 +638,7 @@ var DialogComponent = function DialogComponent(_ref) {
638
638
  started: currentMessage.show,
639
639
  text: currentMessage === null || currentMessage === void 0 ? void 0 : currentMessage.text,
640
640
  audio: currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.audio,
641
+ slide: line,
641
642
  soundActions: soundActions,
642
643
  emitEvent: emitEvent,
643
644
  pauseTTS: pause,
@@ -807,7 +808,10 @@ var DialogComponent = function DialogComponent(_ref) {
807
808
  height: '100vh',
808
809
  position: 'static'
809
810
  };
810
- var disableBackButton = line === 0 || previousLineWasDecision();
811
+ var disableBackButton = (0, _react.useMemo)(function () {
812
+ var disabled = line === 0 || previousLineWasDecision();
813
+ return disabled;
814
+ }, [line, previousLineWasDecision]);
811
815
 
812
816
  if (isDecision) {
813
817
  var decisionPayload = _objectSpread(_objectSpread({}, currentLineData.payload), {}, {
@@ -168,13 +168,6 @@ var ImageClickWrapperComponent = function ImageClickWrapperComponent(props) {
168
168
  shape: 'poly'
169
169
  }, area);
170
170
  });
171
- (0, _react.useEffect)(function () {
172
- if (pause) {
173
- clearInterval(intervalForCountDown.current);
174
- } else {
175
- startCountDown();
176
- }
177
- }, [pause, startCountDown]);
178
171
  var startCountDown = (0, _react.useCallback)(function () {
179
172
  var timeout = setInterval(function () {
180
173
  setCountDownTime(function (t) {
@@ -183,6 +176,13 @@ var ImageClickWrapperComponent = function ImageClickWrapperComponent(props) {
183
176
  }, 1000);
184
177
  intervalForCountDown.current = timeout;
185
178
  }, []);
179
+ (0, _react.useEffect)(function () {
180
+ if (pause) {
181
+ clearInterval(intervalForCountDown.current);
182
+ } else {
183
+ startCountDown();
184
+ }
185
+ }, [pause, startCountDown]);
186
186
  var handleFinish = (0, _react.useCallback)(function (rewards, success) {
187
187
  if (emitFinish) {
188
188
  emitFinish(rewards, success);
@@ -95,7 +95,7 @@ var soundActions = [function (sound) {
95
95
  var exSound = new Audio(sound);
96
96
  exSound.play();
97
97
  }
98
- }, function () {}];
98
+ }, function () {}, function () {}, function () {}];
99
99
  exports.soundActions = soundActions;
100
100
 
101
101
  var setShowPoints = function setShowPoints() {
@@ -35,6 +35,8 @@ var useEkho = function useEkho(_ref) {
35
35
  loop = _ref$loop === void 0 ? false : _ref$loop,
36
36
  _ref$started = _ref.started,
37
37
  started = _ref$started === void 0 ? true : _ref$started,
38
+ _ref$slide = _ref.slide,
39
+ slide = _ref$slide === void 0 ? 0 : _ref$slide,
38
40
  audio = _ref.audio,
39
41
  soundActions = _ref.soundActions,
40
42
  emitEvent = _ref.emitEvent,
@@ -94,16 +96,17 @@ var useEkho = function useEkho(_ref) {
94
96
  var setCurrentPlaying = (0, _react.useCallback)(function (url) {
95
97
  var cc = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'tts';
96
98
 
97
- if (currentPlaying.current.url === url) {
99
+ if (currentPlaying.current.url === url && slide === currentPlaying.current.slide) {
98
100
  return;
99
101
  }
100
102
 
101
103
  currentPlaying.current = {
102
104
  url: url,
103
- cc: cc
105
+ cc: cc,
106
+ slide: slide
104
107
  };
105
108
  playSound(url, cc, loop, volume, onFinish, onStart);
106
- }, [onStart, playSound, loop, onFinish, volume]);
109
+ }, [slide, playSound, loop, volume, onFinish, onStart]);
107
110
  var playSpeech = (0, _react.useCallback)( /*#__PURE__*/function () {
108
111
  var _ref3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(payload) {
109
112
  var url;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@gamelearn/arcade-components",
3
3
  "author": "Gamelearn",
4
4
  "license": "unlicense",
5
- "version": "2.2.5",
5
+ "version": "2.2.8-hotfix",
6
6
  "main": "dist/index.js",
7
7
  "files": [
8
8
  "dist",