@gamelearn/arcade-components 2.35.1 → 2.36.0

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.
@@ -27,6 +27,7 @@ var ComicComponent = function ComicComponent(_ref) {
27
27
  _ref$soundActions = _ref.soundActions,
28
28
  soundActions = _ref$soundActions === void 0 ? [function () {}, function () {}] : _ref$soundActions,
29
29
  autoPlay = _ref.autoPlay,
30
+ autoEnd = _ref.autoEnd,
30
31
  pause = _ref.pause,
31
32
  progress = _ref.progress,
32
33
  keyboardControl = _ref.keyboardControl;
@@ -83,8 +84,10 @@ var ComicComponent = function ComicComponent(_ref) {
83
84
  slide: next
84
85
  }
85
86
  });
87
+ } else if (autoEnd && !pause) {
88
+ close();
86
89
  }
87
- }, [pause, slideCount, slides.length, emitEvent]);
90
+ }, [slideCount, slides.length, pause, autoEnd, emitEvent, close]);
88
91
  var goToPreviousSlide = (0, _react.useCallback)(function () {
89
92
  setStarted(false);
90
93
  setAudioFailed(false);
@@ -46,6 +46,7 @@ var ConversationalProComponent = function ConversationalProComponent(_ref) {
46
46
  soundActions = _ref.soundActions,
47
47
  lodSettings = _ref.lodSettings,
48
48
  autoPlay = _ref.autoPlay,
49
+ autoEnd = _ref.autoEnd,
49
50
  progress = _ref.progress;
50
51
  var defaultLine = (progress === null || progress === void 0 ? void 0 : progress.line) || 0;
51
52
  var _useState = (0, _react.useState)(false),
@@ -342,6 +343,8 @@ var ConversationalProComponent = function ConversationalProComponent(_ref) {
342
343
  line: next
343
344
  }
344
345
  });
346
+ } else if (autoEnd) {
347
+ finishConversation();
345
348
  } else if (currentLineData.decision) {
346
349
  finishConversation();
347
350
  } else {
@@ -350,7 +353,7 @@ var ConversationalProComponent = function ConversationalProComponent(_ref) {
350
353
  if (!isLast) {
351
354
  setStarted(true);
352
355
  }
353
- }, [emitEvent, currentLine, currentLineData.decision, currentLineData.id, finishConversation, handleBranchDirection, handleDecisionBranch, isBranched, lines.length, edgesHistory]);
356
+ }, [autoEnd, emitEvent, currentLine, currentLineData.decision, currentLineData.id, finishConversation, handleBranchDirection, handleDecisionBranch, isBranched, lines.length, edgesHistory]);
354
357
  var handleClickBack = function handleClickBack() {
355
358
  setStarted(false);
356
359
  setTTsStart(false);
@@ -440,14 +443,14 @@ var ConversationalProComponent = function ConversationalProComponent(_ref) {
440
443
  (0, _react.useEffect)(function () {
441
444
  if (autoplayCond && ((currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.audioType) === 'none' || audioFailed)) {
442
445
  // if it's not last node
443
- if (!isEndNode()) {
446
+ if (!isEndNode() || isEndNode() && autoEnd) {
444
447
  start(handleClickNext, autoPlayTime < minMs ? minMs : autoPlayTime);
445
448
  }
446
449
  }
447
450
  return function () {
448
451
  stop();
449
452
  };
450
- }, [currentMessage, start, stop, handleClickNext, currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.audioType, autoplayCond, audioFailed, lines, isEndNode, autoPlayTime]);
453
+ }, [currentMessage, start, stop, handleClickNext, currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.audioType, autoplayCond, audioFailed, autoEnd, lines, isEndNode, autoPlayTime]);
451
454
 
452
455
  // Calculate start node
453
456
  (0, _react.useEffect)(function () {
@@ -51,6 +51,7 @@ var DialogComponent = function DialogComponent(_ref) {
51
51
  soundActions = _ref.soundActions,
52
52
  zoomInActor = _ref.zoomInActor,
53
53
  autoPlay = _ref.autoPlay,
54
+ autoEnd = _ref.autoEnd,
54
55
  pause = _ref.pause,
55
56
  progress = _ref.progress;
56
57
  var defaultLine = (progress === null || progress === void 0 ? void 0 : progress.line) || 0;
@@ -463,6 +464,8 @@ var DialogComponent = function DialogComponent(_ref) {
463
464
  line: next
464
465
  }
465
466
  });
467
+ } else if (autoEnd) {
468
+ finishConversation();
466
469
  } else if (currentLineData.decision) {
467
470
  finishConversation();
468
471
  }
@@ -683,15 +686,14 @@ var DialogComponent = function DialogComponent(_ref) {
683
686
  if (autoPlayCond && currentMessage.show && ((currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.audioType) === 'none' || audioFailed) && !pause) {
684
687
  var _currentMessage$text2;
685
688
  var time = characterMs * ((currentMessage === null || currentMessage === void 0 ? void 0 : (_currentMessage$text2 = currentMessage.text) === null || _currentMessage$text2 === void 0 ? void 0 : _currentMessage$text2.length) || 0);
686
- // if it's not last node
687
- if (!isEndNode()) {
689
+ if (!isEndNode() || isEndNode() && autoEnd) {
688
690
  start(nextLine, time < minMs ? minMs : time);
689
691
  }
690
692
  }
691
693
  return function () {
692
694
  stop();
693
695
  };
694
- }, [currentMessage, nextLine, start, stop, currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.audioType, autoPlayCond, audio, voice, audioFailed]);
696
+ }, [currentMessage, nextLine, start, autoEnd, stop, currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.audioType, autoPlayCond, audio, voice, audioFailed]);
695
697
  var disableBackButton = (0, _react.useMemo)(function () {
696
698
  var disabled = line === 0 || previousLineWasDecision();
697
699
  return disabled;
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.35.1",
5
+ "version": "2.36.0",
6
6
  "main": "dist/index.js",
7
7
  "files": [
8
8
  "dist",