@gamelearn/arcade-components 1.22.10-hotfix-2 → 1.22.11

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.
@@ -80,7 +80,6 @@ var ComicComponent = function ComicComponent(_ref) {
80
80
 
81
81
  var slide = slides === null || slides === void 0 ? void 0 : slides[slideCount];
82
82
  var close = (0, _react.useCallback)(function () {
83
- setStarted(false);
84
83
  emitEvent({
85
84
  type: 'success'
86
85
  });
@@ -121,7 +120,7 @@ var ComicComponent = function ComicComponent(_ref) {
121
120
  goToPreviousSlide();
122
121
  };
123
122
 
124
- (0, _useEkho.default)({
123
+ var stopEkho = (0, _useEkho.default)({
125
124
  audioType: slides === null || slides === void 0 ? void 0 : (_slides$slideCount = slides[slideCount]) === null || _slides$slideCount === void 0 ? void 0 : _slides$slideCount.audioType,
126
125
  voice: slides === null || slides === void 0 ? void 0 : (_slides$slideCount2 = slides[slideCount]) === null || _slides$slideCount2 === void 0 ? void 0 : _slides$slideCount2.voice,
127
126
  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,
@@ -138,6 +137,9 @@ var ComicComponent = function ComicComponent(_ref) {
138
137
  }
139
138
  }
140
139
  });
140
+ (0, _react.useEffect)(function () {
141
+ stopEkho();
142
+ }, [slideCount, stopEkho]);
141
143
  (0, _react.useEffect)(function () {
142
144
  if (automatic && ((slide === null || slide === void 0 ? void 0 : slide.audioType) === 'none' || audioFailed)) {
143
145
  var _slide$vignettes$, _slide$vignettes$$tex;
@@ -262,7 +262,6 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
262
262
  }
263
263
  }, [currentLineData.id, edges, finishConversation, lines]);
264
264
  var handleClickNext = (0, _react.useCallback)(function (choice, reset) {
265
- var isLast = false;
266
265
  setPreviousLineWasDecision(currentLineData.decision);
267
266
  setStarted(false);
268
267
  setAudioFailed(false);
@@ -280,14 +279,11 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
280
279
  if (line + 1 <= maxLine) {
281
280
  setCurrentLine(line + 1);
282
281
  } else {
283
- isLast = true;
284
282
  finishConversation();
285
283
  }
286
284
  }
287
285
 
288
- if (!isLast) {
289
- setStarted(true);
290
- }
286
+ setStarted(true);
291
287
  }, [currentLine, currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.decision, finishConversation, handleBranchDirection, handleDecisionBranch, isBranched, lines.length]);
292
288
 
293
289
  var handleClickBack = function handleClickBack() {
@@ -317,7 +313,7 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
317
313
 
318
314
  var autoplayCond = automatic && !isDecision;
319
315
  var disableBackButton = currentLine === 0 || previousLineWasDecision || currentLine > 0 && (lastLine === null || lastLine === void 0 ? void 0 : lastLine.decision);
320
- (0, _useEkho.default)({
316
+ var stopEkho = (0, _useEkho.default)({
321
317
  audioType: currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.audioType,
322
318
  voice: currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.voice,
323
319
  started: started,
@@ -333,7 +329,10 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
333
329
  handleClickNext();
334
330
  }
335
331
  }
336
- }); // Autoplay logic
332
+ });
333
+ (0, _react.useEffect)(function () {
334
+ stopEkho();
335
+ }, [currentLine, stopEkho]); // Autoplay logic
337
336
 
338
337
  (0, _react.useEffect)(function () {
339
338
  if (autoplayCond && ((currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.audioType) === 'none' || audioFailed)) {
@@ -540,9 +540,6 @@ var DialogComponent = function DialogComponent(_ref) {
540
540
  });
541
541
  (0, _react.useEffect)(function () {
542
542
  stopEkho();
543
- return function () {
544
- stopEkho();
545
- };
546
543
  }, [line, stopEkho]); // Autoplay logic
547
544
 
548
545
  (0, _react.useEffect)(function () {
@@ -7,6 +7,12 @@ exports.default = void 0;
7
7
 
8
8
  var _react = require("react");
9
9
 
10
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
11
+
12
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
13
+
14
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
15
+
10
16
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
11
17
 
12
18
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
@@ -65,7 +71,14 @@ var useEkho = function useEkho(_ref) {
65
71
  type: 'translate',
66
72
  payload: id
67
73
  });
68
- }, [emitEvent]); // Get translated voices, todo: translate this in arcade translateProps i18n.helper.js
74
+ }, [emitEvent]); // Setted when is mounted
75
+
76
+ (0, _react.useEffect)(function () {
77
+ setIsMounted(true);
78
+ return function () {
79
+ setIsMounted(false);
80
+ };
81
+ }, []); // Get translated voices, todo: translate this in arcade translateProps i18n.helper.js
69
82
 
70
83
  var getVoice = (0, _react.useCallback)(function (_ref2) {
71
84
  var id = _ref2.id,
@@ -110,7 +123,7 @@ var useEkho = function useEkho(_ref) {
110
123
  while (1) {
111
124
  switch (_context.prev = _context.next) {
112
125
  case 0:
113
- if (!(isMounted && payload.voiceId && payload.text)) {
126
+ if (!(payload.voiceId && payload.text)) {
114
127
  _context.next = 7;
115
128
  break;
116
129
  }
@@ -147,32 +160,21 @@ var useEkho = function useEkho(_ref) {
147
160
  return function (_x) {
148
161
  return _ref3.apply(this, arguments);
149
162
  };
150
- }(), [emitEvent, isMounted, onError, setCurrentPlaying]);
163
+ }(), [emitEvent, onError, setCurrentPlaying]);
151
164
  var stopCurrentAudio = (0, _react.useCallback)(function () {
152
165
  if (currentPlaying.current.url) {
153
- currentPlaying.current = {
154
- url: '',
155
- cc: 'tts'
156
- };
166
+ currentPlaying.current = _objectSpread(_objectSpread({}, currentPlaying.current), {}, {
167
+ url: ''
168
+ });
157
169
  stop(currentPlaying.current.cc);
158
170
  }
159
- }, [stop]); // Setted when is mounted
160
-
161
- (0, _react.useEffect)(function () {
162
- setIsMounted(true);
163
- return function () {
164
- setIsMounted(false);
165
- stopCurrentAudio();
166
- };
167
- }, [stopCurrentAudio]);
171
+ }, [stop]);
168
172
  (0, _react.useEffect)(function () {
169
173
  if (noAudio) {
170
174
  stopCurrentAudio();
171
175
  }
172
176
  }, [noAudio, stopCurrentAudio]);
173
177
  (0, _react.useEffect)(function () {
174
- stopCurrentAudio();
175
-
176
178
  if (isMounted && started) {
177
179
  if (audioType === 'voice' && voice !== null && voice !== void 0 && voice.id) {
178
180
  var voiceId = getVoice(voice);
@@ -186,7 +188,7 @@ var useEkho = function useEkho(_ref) {
186
188
  onError();
187
189
  }
188
190
  }
189
- }, [getVoice, playSpeech, isMounted, voice, text, audioType, audio === null || audio === void 0 ? void 0 : audio.url, audio, setCurrentPlaying, onError, started, stopCurrentAudio]);
191
+ }, [getVoice, playSpeech, isMounted, voice, text, audioType, audio === null || audio === void 0 ? void 0 : audio.url, audio, setCurrentPlaying, onError, started]);
190
192
  return stopCurrentAudio;
191
193
  };
192
194
 
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.22.10-hotfix-2",
5
+ "version": "1.22.11",
6
6
  "main": "dist/index.js",
7
7
  "files": [
8
8
  "dist",
@@ -109,4 +109,4 @@
109
109
  "post-merge": "bash node_modules/@gamelearn/version/scripts/after_version_update.sh -p hooks.config"
110
110
  }
111
111
  }
112
- }
112
+ }