@gamelearn/arcade-components 1.22.8 → 1.22.10-hotfix-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.
@@ -120,7 +120,7 @@ var ComicComponent = function ComicComponent(_ref) {
120
120
  goToPreviousSlide();
121
121
  };
122
122
 
123
- var stopEkho = (0, _useEkho.default)({
123
+ (0, _useEkho.default)({
124
124
  audioType: slides === null || slides === void 0 ? void 0 : (_slides$slideCount = slides[slideCount]) === null || _slides$slideCount === void 0 ? void 0 : _slides$slideCount.audioType,
125
125
  voice: slides === null || slides === void 0 ? void 0 : (_slides$slideCount2 = slides[slideCount]) === null || _slides$slideCount2 === void 0 ? void 0 : _slides$slideCount2.voice,
126
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,
@@ -137,9 +137,6 @@ var ComicComponent = function ComicComponent(_ref) {
137
137
  }
138
138
  }
139
139
  });
140
- (0, _react.useEffect)(function () {
141
- stopEkho();
142
- }, [slideCount, stopEkho]);
143
140
  (0, _react.useEffect)(function () {
144
141
  if (automatic && ((slide === null || slide === void 0 ? void 0 : slide.audioType) === 'none' || audioFailed)) {
145
142
  var _slide$vignettes$, _slide$vignettes$$tex;
@@ -61,25 +61,30 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
61
61
  lodSettings = _ref.lodSettings,
62
62
  autoPlay = _ref.autoPlay;
63
63
 
64
- var _useState = (0, _react.useState)(true),
64
+ var _useState = (0, _react.useState)(false),
65
65
  _useState2 = _slicedToArray(_useState, 2),
66
- started = _useState2[0],
67
- setStarted = _useState2[1];
66
+ mounted = _useState2[0],
67
+ setMounted = _useState2[1];
68
68
 
69
- var _useState3 = (0, _react.useState)(!!autoPlay),
69
+ var _useState3 = (0, _react.useState)(true),
70
70
  _useState4 = _slicedToArray(_useState3, 2),
71
- automatic = _useState4[0],
72
- setAutomatic = _useState4[1];
71
+ started = _useState4[0],
72
+ setStarted = _useState4[1];
73
73
 
74
- var _useState5 = (0, _react.useState)(false),
74
+ var _useState5 = (0, _react.useState)(!!autoPlay),
75
75
  _useState6 = _slicedToArray(_useState5, 2),
76
- audioFailed = _useState6[0],
77
- setAudioFailed = _useState6[1];
76
+ automatic = _useState6[0],
77
+ setAutomatic = _useState6[1];
78
78
 
79
- var _useState7 = (0, _react.useState)(0),
79
+ var _useState7 = (0, _react.useState)(false),
80
80
  _useState8 = _slicedToArray(_useState7, 2),
81
- currentLine = _useState8[0],
82
- setCurrentLine = _useState8[1];
81
+ audioFailed = _useState8[0],
82
+ setAudioFailed = _useState8[1];
83
+
84
+ var _useState9 = (0, _react.useState)(0),
85
+ _useState10 = _slicedToArray(_useState9, 2),
86
+ currentLine = _useState10[0],
87
+ setCurrentLine = _useState10[1];
83
88
 
84
89
  var _soundActions = _slicedToArray(soundActions, 1),
85
90
  playSound = _soundActions[0];
@@ -95,10 +100,10 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
95
100
  decision = currentLineData.decision;
96
101
  var isBranched = !!edges;
97
102
 
98
- var _useState9 = (0, _react.useState)(false),
99
- _useState10 = _slicedToArray(_useState9, 2),
100
- previousLineWasDecision = _useState10[0],
101
- setPreviousLineWasDecision = _useState10[1];
103
+ var _useState11 = (0, _react.useState)(false),
104
+ _useState12 = _slicedToArray(_useState11, 2),
105
+ previousLineWasDecision = _useState12[0],
106
+ setPreviousLineWasDecision = _useState12[1];
102
107
 
103
108
  var isVoiceOver = voiceOver || currentLineData.type === 'conversationalNarration';
104
109
  var isDecision = decision || currentLineData.type === 'conversationalDecision';
@@ -279,7 +284,7 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
279
284
  }
280
285
 
281
286
  setStarted(true);
282
- }, [currentLine, currentLineData, finishConversation, handleBranchDirection, handleDecisionBranch, isBranched, lines.length]);
287
+ }, [currentLine, currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.decision, finishConversation, handleBranchDirection, handleDecisionBranch, isBranched, lines.length]);
283
288
 
284
289
  var handleClickBack = function handleClickBack() {
285
290
  setStarted(false);
@@ -308,7 +313,7 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
308
313
 
309
314
  var autoplayCond = automatic && !isDecision;
310
315
  var disableBackButton = currentLine === 0 || previousLineWasDecision || currentLine > 0 && (lastLine === null || lastLine === void 0 ? void 0 : lastLine.decision);
311
- var stopEkho = (0, _useEkho.default)({
316
+ (0, _useEkho.default)({
312
317
  audioType: currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.audioType,
313
318
  voice: currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.voice,
314
319
  started: started,
@@ -324,10 +329,7 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
324
329
  handleClickNext();
325
330
  }
326
331
  }
327
- });
328
- (0, _react.useEffect)(function () {
329
- stopEkho();
330
- }, [currentLine, stopEkho]); // Autoplay logic
332
+ }); // Autoplay logic
331
333
 
332
334
  (0, _react.useEffect)(function () {
333
335
  if (autoplayCond && ((currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.audioType) === 'none' || audioFailed)) {
@@ -340,7 +342,27 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
340
342
  return function () {
341
343
  stop();
342
344
  };
343
- }, [currentMessage, start, stop, handleClickNext, currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.audioType, autoplayCond, audioFailed]);
345
+ }, [currentMessage, start, stop, handleClickNext, currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.audioType, autoplayCond, audioFailed, lines]); // Calculate start node
346
+
347
+ (0, _react.useEffect)(function () {
348
+ if (isBranched && !mounted) {
349
+ var startNodes = lines.filter(function (node) {
350
+ return !edges.find(function (edge) {
351
+ return edge.toId === node.id;
352
+ });
353
+ });
354
+
355
+ if (startNodes.length) {
356
+ var initialNode = startNodes[0];
357
+ var newInitiaIndexlNode = lines.indexOf(initialNode);
358
+
359
+ if (newInitiaIndexlNode >= 0) {
360
+ setMounted(true);
361
+ setCurrentLine(newInitiaIndexlNode);
362
+ }
363
+ }
364
+ }
365
+ }, [edges, isBranched, lines, mounted]);
344
366
 
345
367
  var decisionPayload = _objectSpread(_objectSpread({}, currentLineData.payload), {}, {
346
368
  required: !isBranched,
@@ -45,6 +45,14 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
45
45
 
46
46
  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; }
47
47
 
48
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
49
+
50
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
51
+
52
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
53
+
54
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
55
+
48
56
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
49
57
 
50
58
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
@@ -102,8 +110,13 @@ var DialogComponent = function DialogComponent(_ref) {
102
110
 
103
111
  var _useState7 = (0, _react.useState)(false),
104
112
  _useState8 = _slicedToArray(_useState7, 2),
105
- audioFailed = _useState8[0],
106
- setAudioFailed = _useState8[1];
113
+ mounted = _useState8[0],
114
+ setMounted = _useState8[1];
115
+
116
+ var _useState9 = (0, _react.useState)(false),
117
+ _useState10 = _slicedToArray(_useState9, 2),
118
+ audioFailed = _useState10[0],
119
+ setAudioFailed = _useState10[1];
107
120
 
108
121
  var _useThree = (0, _fiber.useThree)(function (state) {
109
122
  return [state.camera, state.scene];
@@ -140,6 +153,20 @@ var DialogComponent = function DialogComponent(_ref) {
140
153
  voiceOver = _ref2.voiceOver,
141
154
  decision = _ref2.decision;
142
155
 
156
+ var charactersInvolved = (0, _react.useMemo)(function () {
157
+ return lines.reduce(function (acc, current) {
158
+ if (current.slots) {
159
+ var participants = current.slots.filter(function (slot) {
160
+ return slot.uid;
161
+ });
162
+ participants.forEach(function (currentParticipant) {
163
+ if (!acc.includes(currentParticipant.uid)) acc.push(currentParticipant.uid);
164
+ });
165
+ }
166
+
167
+ return acc;
168
+ }, []);
169
+ }, [lines]);
143
170
  var translate = (0, _react.useCallback)(function (id) {
144
171
  return emitEvent({
145
172
  type: 'translate',
@@ -147,10 +174,10 @@ var DialogComponent = function DialogComponent(_ref) {
147
174
  });
148
175
  }, [emitEvent]);
149
176
 
150
- var _useState9 = (0, _react.useState)(false),
151
- _useState10 = _slicedToArray(_useState9, 2),
152
- previousLineWasDecision = _useState10[0],
153
- setPreviousLineWasDecision = _useState10[1];
177
+ var _useState11 = (0, _react.useState)(false),
178
+ _useState12 = _slicedToArray(_useState11, 2),
179
+ previousLineWasDecision = _useState12[0],
180
+ setPreviousLineWasDecision = _useState12[1];
154
181
 
155
182
  var isVoiceOver = voiceOver || (currentLine === null || currentLine === void 0 ? void 0 : currentLine.type) === 'conversationalNarration';
156
183
  var isDecision = decision || (currentLine === null || currentLine === void 0 ? void 0 : currentLine.type) === 'conversationalDecision';
@@ -179,10 +206,10 @@ var DialogComponent = function DialogComponent(_ref) {
179
206
  var _slot$character2;
180
207
 
181
208
  var onLoadAnim = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function () {};
182
- var animation = (_slot$character2 = slot.character) === null || _slot$character2 === void 0 ? void 0 : _slot$character2.resource.animations[slot.emotion];
209
+ var animation = (_slot$character2 = slot.character) === null || _slot$character2 === void 0 ? void 0 : _slot$character2.resource.animations[element.isSeated ? "".concat(slot.emotion, "-seated") : slot.emotion];
183
210
  var mixer = element.userData.mixer;
184
211
 
185
- if (animation && animation.url && !element.isSeated) {
212
+ if (animation && animation.url) {
186
213
  loader.load(animation.url, function (anim) {
187
214
  var emotionClip = anim.animations[0];
188
215
  var defaultClip = element.userData.defaultAnim;
@@ -201,31 +228,31 @@ var DialogComponent = function DialogComponent(_ref) {
201
228
  }
202
229
  }, [loader]);
203
230
 
204
- var executeAnimation = function executeAnimation(element) {
205
- var mixer = element.userData.mixer;
206
- var startAction = mixer.clipAction(element.userData.currentEmotion.getClip(), element);
207
- var defaultAction = mixer.clipAction(element.userData.defaultAnim, element);
231
+ var executeDefaultAnimation = function executeDefaultAnimation(element) {
232
+ if (element.userData.mixer && element.userData.currentEmotion) {
233
+ var mixer = element.userData.mixer;
234
+ var startAction = mixer.clipAction(element.userData.currentEmotion.getClip(), element);
235
+ var defaultAction = mixer.clipAction(element.userData.defaultAnim, element);
208
236
 
209
- if (element.userData.currentEmotion !== defaultAction) {
210
- setTimeout(function () {
211
- mixer.stopAllAction();
212
- (0, _helpers.executeCrossFade)(startAction, defaultAction, crossFadeDuration / Math.floor(Math.random() * 3));
237
+ if (element.userData.currentEmotion !== defaultAction) {
238
+ setTimeout(function () {
239
+ mixer.stopAllAction();
240
+ (0, _helpers.executeCrossFade)(startAction, defaultAction, crossFadeDuration / Math.floor(Math.random() * 3));
213
241
 
214
- if (element.userData.currentEmotion) {
215
- element.userData.lastEmotion = element.userData.currentEmotion;
216
- }
242
+ if (element.userData.currentEmotion) {
243
+ element.userData.lastEmotion = element.userData.currentEmotion;
244
+ }
217
245
 
218
- element.userData.currentEmotion = defaultAction;
219
- }, Math.floor(Math.random() * 3) * 500);
246
+ element.userData.currentEmotion = defaultAction;
247
+ }, Math.floor(Math.random() * 3) * 500);
248
+ }
220
249
  }
221
250
  }; // Reset currentEmotion to defaultAnim
222
251
 
223
252
 
224
253
  var resetAnims = (0, _react.useCallback)(function () {
225
254
  scene.traverseVisible(function (node) {
226
- if (node.userData.mixer && node.userData.currentEmotion) {
227
- executeAnimation(node);
228
- }
255
+ return executeDefaultAnimation(node);
229
256
  });
230
257
  }, [scene]);
231
258
  var resetCameraView = (0, _react.useCallback)(function () {
@@ -327,7 +354,7 @@ var DialogComponent = function DialogComponent(_ref) {
327
354
  } else {
328
355
  finishConversation();
329
356
  }
330
- }, [currentLineData.decision, isBranched, line, lines.length, handleDecisionBranch, handleBranchDirection, finishConversation]);
357
+ }, [currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.decision, isBranched, line, lines.length, handleDecisionBranch, handleBranchDirection, finishConversation]);
331
358
 
332
359
  var manualBackLine = function manualBackLine() {
333
360
  setAutomatic(false);
@@ -337,9 +364,29 @@ var DialogComponent = function DialogComponent(_ref) {
337
364
  var manualNextLine = function manualNextLine() {
338
365
  setAutomatic(false);
339
366
  nextLine();
340
- }; // Position bubble over talking character/and switch emotions
367
+ }; // Calculate start node
341
368
 
342
369
 
370
+ (0, _react.useEffect)(function () {
371
+ if (isBranched && !mounted) {
372
+ var startNodes = lines.filter(function (node) {
373
+ return !edges.find(function (edge) {
374
+ return edge.toId === node.id;
375
+ });
376
+ });
377
+
378
+ if (startNodes.length) {
379
+ var initialNode = startNodes[0];
380
+ var newInitiaIndexlNode = lines.indexOf(initialNode);
381
+
382
+ if (newInitiaIndexlNode >= 0) {
383
+ setMounted(true);
384
+ changeLine(newInitiaIndexlNode);
385
+ }
386
+ }
387
+ }
388
+ }, [edges, isBranched, lines, mounted]); // Position bubble over talking character/and switch emotions
389
+
343
390
  (0, _react.useEffect)(function () {
344
391
  if (isDecision) {
345
392
  resetCameraView();
@@ -362,6 +409,19 @@ var DialogComponent = function DialogComponent(_ref) {
362
409
  });
363
410
  var slottedCharacters = currentLine === null || currentLine === void 0 ? void 0 : currentLine.slots.filter(function (slot) {
364
411
  return slot.uid && !slot.talking;
412
+ });
413
+ var currentParticipants = [].concat(_toConsumableArray(slottedCharacters.map(function (slot) {
414
+ return slot.uid;
415
+ }) || []), [talkingCharacter.uid]);
416
+ var notInvolvedParticipants = charactersInvolved.filter(function (charUid) {
417
+ return !currentParticipants.includes(charUid);
418
+ });
419
+ notInvolvedParticipants.forEach(function (uid) {
420
+ var element = getCurrentVisible(uid);
421
+
422
+ if (element) {
423
+ executeDefaultAnimation(element);
424
+ }
365
425
  }); // Check not talking elements emotion
366
426
 
367
427
  slottedCharacters.forEach(function (slot) {
@@ -395,45 +455,45 @@ var DialogComponent = function DialogComponent(_ref) {
395
455
  mixer.stopAllAction();
396
456
  (0, _helpers.executeCrossFade)(startAction, action, crossFadeDuration);
397
457
  }
398
- });
399
-
400
- if (talkingCharacter.uid === element.uid) {
401
- var showArrowTop = talkingCharacter.text.length > maxCharacterToSwitch;
402
- var head = element.getObjectByName('Head_M');
403
- var target = new _three.Object3D();
404
- head.getWorldPosition(target.position);
405
- target.applyQuaternion(camera.quaternion);
406
- target.translateX(1.25);
407
- var distance = camera.position.distanceTo(target.position);
408
- var staticDisplay = distance > 70 && !zoomInActor && !showArrowTop;
409
- target.translateY(staticDisplay || showArrowTop ? 0 : 3);
410
- messagePosition.current = {
411
- pos: target.position.toArray(),
412
- child: head,
413
- parent: element
414
- };
415
-
416
- if (zoomInActor) {
417
- animationStart.current = true;
418
- } // Ugly timeout to wait for zoom in ( maybe use tween (?))
419
458
 
420
-
421
- setTimeout(function () {
422
- var _talkingCharacter$cha;
423
-
424
- distance = camera.position.distanceTo(target.position);
425
- setCurrentMessage({
426
- text: talkingCharacter.text,
427
- name: talkingCharacter.alias || ((_talkingCharacter$cha = talkingCharacter.character) === null || _talkingCharacter$cha === void 0 ? void 0 : _talkingCharacter$cha.name),
428
- left: true,
429
- top: showArrowTop || distance > 70,
430
- inScene: true,
431
- thinkful: talkingCharacter.emotion === 'thinkful',
432
- avatar: '',
433
- show: true
434
- });
435
- }, zoomInActor ? 1200 : 0);
436
- }
459
+ if (talkingCharacter.uid === element.uid) {
460
+ var showArrowTop = talkingCharacter.text.length > maxCharacterToSwitch;
461
+ var head = element.getObjectByName('Head_M');
462
+ var target = new _three.Object3D();
463
+ head.getWorldPosition(target.position);
464
+ target.applyQuaternion(camera.quaternion);
465
+ target.translateX(1.25);
466
+ var distance = camera.position.distanceTo(target.position);
467
+ var staticDisplay = distance > 70 && !zoomInActor && !showArrowTop;
468
+ target.translateY(staticDisplay || showArrowTop ? 0 : 3);
469
+ messagePosition.current = {
470
+ pos: target.position.toArray(),
471
+ child: head,
472
+ parent: element
473
+ };
474
+
475
+ if (zoomInActor) {
476
+ animationStart.current = true;
477
+ } // Ugly timeout to wait for zoom in ( maybe use tween (?))
478
+
479
+
480
+ setTimeout(function () {
481
+ var _talkingCharacter$cha;
482
+
483
+ distance = camera.position.distanceTo(target.position);
484
+ setCurrentMessage({
485
+ text: talkingCharacter.text,
486
+ name: talkingCharacter.alias || ((_talkingCharacter$cha = talkingCharacter.character) === null || _talkingCharacter$cha === void 0 ? void 0 : _talkingCharacter$cha.name),
487
+ left: true,
488
+ top: showArrowTop || distance > 70,
489
+ inScene: true,
490
+ thinkful: talkingCharacter.emotion === 'thinkful',
491
+ avatar: '',
492
+ show: true
493
+ });
494
+ }, zoomInActor ? 1200 : 0);
495
+ }
496
+ });
437
497
  } else {
438
498
  var _talkingCharacter$cha2;
439
499
 
@@ -456,7 +516,7 @@ var DialogComponent = function DialogComponent(_ref) {
456
516
  });
457
517
  }
458
518
  }
459
- }, [actors, camera, currentLine, zoomInActor, getCurrentVisible, translate, getAvatarURL, loadEmotion, resetCameraView, isDecision, isVoiceOver]);
519
+ }, [actors, camera, currentLine, zoomInActor, getCurrentVisible, translate, getAvatarURL, loadEmotion, resetCameraView, isDecision, isVoiceOver, charactersInvolved]);
460
520
  var autoPlayCond = automatic && !(currentLine !== null && currentLine !== void 0 && currentLine.decision);
461
521
  var audio = Object.keys((currentLine === null || currentLine === void 0 ? void 0 : currentLine.audio) || {}).length;
462
522
  var voice = Object.keys((currentLine === null || currentLine === void 0 ? void 0 : currentLine.voice) || {}).length; // Sound logic
@@ -480,6 +540,9 @@ var DialogComponent = function DialogComponent(_ref) {
480
540
  });
481
541
  (0, _react.useEffect)(function () {
482
542
  stopEkho();
543
+ return function () {
544
+ stopEkho();
545
+ };
483
546
  }, [line, stopEkho]); // Autoplay logic
484
547
 
485
548
  (0, _react.useEffect)(function () {
@@ -7,12 +7,6 @@ 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
-
16
10
  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); } }
17
11
 
18
12
  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); }); }; }
@@ -163,9 +157,10 @@ var useEkho = function useEkho(_ref) {
163
157
  }(), [emitEvent, onError, setCurrentPlaying]);
164
158
  var stopCurrentAudio = (0, _react.useCallback)(function () {
165
159
  if (currentPlaying.current.url) {
166
- currentPlaying.current = _objectSpread(_objectSpread({}, currentPlaying.current), {}, {
167
- url: ''
168
- });
160
+ currentPlaying.current = {
161
+ url: '',
162
+ cc: 'tts'
163
+ };
169
164
  stop(currentPlaying.current.cc);
170
165
  }
171
166
  }, [stop]);
@@ -176,6 +171,8 @@ var useEkho = function useEkho(_ref) {
176
171
  }, [noAudio, stopCurrentAudio]);
177
172
  (0, _react.useEffect)(function () {
178
173
  if (isMounted && started) {
174
+ stopCurrentAudio();
175
+
179
176
  if (audioType === 'voice' && voice !== null && voice !== void 0 && voice.id) {
180
177
  var voiceId = getVoice(voice);
181
178
  playSpeech({
@@ -188,7 +185,7 @@ var useEkho = function useEkho(_ref) {
188
185
  onError();
189
186
  }
190
187
  }
191
- }, [getVoice, playSpeech, isMounted, voice, text, audioType, audio === null || audio === void 0 ? void 0 : audio.url, audio, setCurrentPlaying, onError, started]);
188
+ }, [getVoice, playSpeech, isMounted, voice, text, audioType, audio === null || audio === void 0 ? void 0 : audio.url, audio, setCurrentPlaying, onError, started, stopCurrentAudio]);
192
189
  return stopCurrentAudio;
193
190
  };
194
191
 
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.8",
5
+ "version": "1.22.10-hotfix-1",
6
6
  "main": "dist/index.js",
7
7
  "files": [
8
8
  "dist",