@gamelearn/arcade-components 2.2.3 → 2.2.7
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.
- package/dist/components/auto-evaluation-component/components/AutoEvaluation.js +4 -2
- package/dist/components/cards-selector-puzzle-component/components/CardsSelectorPuzzleComponent.js +6 -3
- package/dist/components/chained-image-click-puzzle-component/components/CurrentImagePuzzle.js +20 -8
- package/dist/components/comic-component/components/ComicComponent.js +3 -4
- package/dist/components/conversational-pro-component/components/ConversationalProComponent.js +148 -49
- package/dist/components/conversational-pro-component/components/SlotList.js +6 -2
- package/dist/components/conversational-pro-component/components/scene/Panel.js +72 -10
- package/dist/components/conversational-pro-component/components/scene/Panels.js +3 -1
- package/dist/components/conversational-pro-component/components/scene/index.js +8 -1
- package/dist/components/dialog-component/components/DialogComponent.js +206 -81
- package/dist/components/feedback-component/components/FeedbackComponent.js +2 -3
- package/dist/components/frame-click-puzzle-component/components/CurrentFramePuzzle.js +16 -3
- package/dist/components/frame-click-puzzle-component/components/FrameClickPuzzleComponent.js +4 -2
- package/dist/components/image-click-wrapper-component/components/ImageClickWrapperComponent.js +9 -1
- package/dist/components/lectures-component/components/LecturesComponent.js +1 -1
- package/dist/components/survey-component/components/SurveyComponent.js +4 -2
- package/dist/components/terminal-puzzle-component/components/Visor/index.js +1 -1
- package/dist/components/test-component/components/Container.js +4 -3
- package/dist/components/test-component/components/TestComponent.js +11 -4
- package/dist/helpers/index.js +70 -4
- package/dist/helpers/mocker.js +1 -1
- package/dist/helpers/useEkho.js +20 -11
- package/package.json +1 -1
|
@@ -106,7 +106,9 @@ var AutoEvaluation = function AutoEvaluation(_ref) {
|
|
|
106
106
|
}
|
|
107
107
|
};
|
|
108
108
|
|
|
109
|
-
return /*#__PURE__*/_react.default.createElement("div", {
|
|
109
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
110
|
+
className: "test--container__overlay"
|
|
111
|
+
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
110
112
|
className: "test--container",
|
|
111
113
|
dir: "auto"
|
|
112
114
|
}, phase === 'start' && /*#__PURE__*/_react.default.createElement(_StartScreen.default, {
|
|
@@ -157,7 +159,7 @@ var AutoEvaluation = function AutoEvaluation(_ref) {
|
|
|
157
159
|
})))), phase === 'end' && /*#__PURE__*/_react.default.createElement(_EndScreen.default, {
|
|
158
160
|
onFinish: close,
|
|
159
161
|
translate: translate
|
|
160
|
-
}));
|
|
162
|
+
})));
|
|
161
163
|
};
|
|
162
164
|
|
|
163
165
|
var _default = AutoEvaluation;
|
package/dist/components/cards-selector-puzzle-component/components/CardsSelectorPuzzleComponent.js
CHANGED
|
@@ -142,6 +142,11 @@ var CardsSelectorPuzzleComponent = function CardsSelectorPuzzleComponent(_ref) {
|
|
|
142
142
|
|
|
143
143
|
var onFinish = function onFinish() {
|
|
144
144
|
setFinished(true);
|
|
145
|
+
|
|
146
|
+
if (info.solution.right.desc && !(specificFeedbacks !== null && specificFeedbacks !== void 0 && specificFeedbacks.specificCorrectFeedbacks)) {
|
|
147
|
+
setFeedBackText(info.solution.right.desc);
|
|
148
|
+
setFeedbackIsShown(true);
|
|
149
|
+
}
|
|
145
150
|
};
|
|
146
151
|
|
|
147
152
|
var handleFeedbackFuncionOnClose = function handleFeedbackFuncionOnClose() {
|
|
@@ -170,13 +175,11 @@ var CardsSelectorPuzzleComponent = function CardsSelectorPuzzleComponent(_ref) {
|
|
|
170
175
|
|
|
171
176
|
if (pickedCard !== null && pickedCard !== void 0 && pickedCard.desc) {
|
|
172
177
|
setFeedBackText(pickedCard.desc);
|
|
178
|
+
setFeedbackIsShown(true);
|
|
173
179
|
}
|
|
174
|
-
} else if (info.solution.right.desc) {
|
|
175
|
-
setFeedBackText(info.solution.right.desc);
|
|
176
180
|
}
|
|
177
181
|
|
|
178
182
|
playSound('score');
|
|
179
|
-
setFeedbackIsShown(true);
|
|
180
183
|
emitEvent({
|
|
181
184
|
type: 'hidePuzzleButtons',
|
|
182
185
|
payload: true
|
package/dist/components/chained-image-click-puzzle-component/components/CurrentImagePuzzle.js
CHANGED
|
@@ -46,6 +46,8 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
|
|
|
46
46
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
47
47
|
|
|
48
48
|
var CurrentImageClickPuzzle = function CurrentImageClickPuzzle(_ref) {
|
|
49
|
+
var _specificFeedbacks$co2;
|
|
50
|
+
|
|
49
51
|
var list = _ref.list,
|
|
50
52
|
description = _ref.description,
|
|
51
53
|
nodeId = _ref.nodeId,
|
|
@@ -55,9 +57,11 @@ var CurrentImageClickPuzzle = function CurrentImageClickPuzzle(_ref) {
|
|
|
55
57
|
setResolveAction = _ref.setResolveAction,
|
|
56
58
|
soundActions = _ref.soundActions,
|
|
57
59
|
setSelected = _ref.setSelected,
|
|
58
|
-
selected = _ref.selected
|
|
60
|
+
selected = _ref.selected,
|
|
61
|
+
pause = _ref.pause;
|
|
59
62
|
var accRewards = (0, _react.useRef)([]);
|
|
60
63
|
var correctClicked = (0, _react.useRef)(0);
|
|
64
|
+
var currentSelected = (0, _react.useRef)(0);
|
|
61
65
|
|
|
62
66
|
var _useState = (0, _react.useState)(0),
|
|
63
67
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -103,6 +107,7 @@ var CurrentImageClickPuzzle = function CurrentImageClickPuzzle(_ref) {
|
|
|
103
107
|
info.description = description;
|
|
104
108
|
(0, _react.useEffect)(function () {
|
|
105
109
|
correctClicked.current = 0;
|
|
110
|
+
currentSelected.current = 0;
|
|
106
111
|
}, [index]);
|
|
107
112
|
var onComplete = (0, _react.useCallback)(function (rw) {
|
|
108
113
|
var correct = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
@@ -114,7 +119,14 @@ var CurrentImageClickPuzzle = function CurrentImageClickPuzzle(_ref) {
|
|
|
114
119
|
if (specificFeedbacks !== null && specificFeedbacks !== void 0 && (_specificFeedbacks$co = specificFeedbacks.correctFeedbacks) !== null && _specificFeedbacks$co !== void 0 && _specificFeedbacks$co.length && !currentImageProps.hasClickOnce && !finish) {
|
|
115
120
|
correctClicked.current += 1;
|
|
116
121
|
} else {
|
|
117
|
-
|
|
122
|
+
var total = selected;
|
|
123
|
+
|
|
124
|
+
if (currentSelected.current) {
|
|
125
|
+
total -= currentSelected.current;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
correctClicked.current = currentImageProps.areas.length;
|
|
129
|
+
setSelected(total + correctClicked.current);
|
|
118
130
|
}
|
|
119
131
|
|
|
120
132
|
if (correctClicked.current === currentImageProps.areas.length) {
|
|
@@ -142,7 +154,7 @@ var CurrentImageClickPuzzle = function CurrentImageClickPuzzle(_ref) {
|
|
|
142
154
|
type: 'failPuzzle'
|
|
143
155
|
});
|
|
144
156
|
}
|
|
145
|
-
}, [
|
|
157
|
+
}, [specificFeedbacks === null || specificFeedbacks === void 0 ? void 0 : (_specificFeedbacks$co2 = specificFeedbacks.correctFeedbacks) === null || _specificFeedbacks$co2 === void 0 ? void 0 : _specificFeedbacks$co2.length, currentImageProps.hasClickOnce, currentImageProps.areas.length, currentImageProps.hasClickOrder, index, list.length, handleFinish, emitEvent, setSelected, selected]);
|
|
146
158
|
|
|
147
159
|
var onResolve = function onResolve() {
|
|
148
160
|
playSound('score');
|
|
@@ -168,12 +180,11 @@ var CurrentImageClickPuzzle = function CurrentImageClickPuzzle(_ref) {
|
|
|
168
180
|
resolvedItems.current[puzzleId] = true;
|
|
169
181
|
}
|
|
170
182
|
}, [onComplete, puzzleId, currentPuzzleStatus]);
|
|
171
|
-
|
|
172
|
-
var checkSelectedAreas = function checkSelectedAreas() {
|
|
183
|
+
var checkSelectedAreas = (0, _react.useCallback)(function () {
|
|
173
184
|
var areasSelected = currentImageProps.hasClickOnce ? currentImageProps.areas.length : 1;
|
|
185
|
+
currentSelected.current += areasSelected;
|
|
174
186
|
setSelected(selected + areasSelected);
|
|
175
|
-
};
|
|
176
|
-
|
|
187
|
+
}, [currentImageProps.areas.length, currentImageProps.hasClickOnce, selected, setSelected]);
|
|
177
188
|
return /*#__PURE__*/_react.default.createElement(_imageClickWrapperComponent.default, _extends({
|
|
178
189
|
key: index
|
|
179
190
|
}, currentImageProps, {
|
|
@@ -192,7 +203,8 @@ var CurrentImageClickPuzzle = function CurrentImageClickPuzzle(_ref) {
|
|
|
192
203
|
emitEvent: emitEvent,
|
|
193
204
|
disableExit: disableExit,
|
|
194
205
|
soundActions: soundActions,
|
|
195
|
-
setResolveAction: setResolveAction
|
|
206
|
+
setResolveAction: setResolveAction,
|
|
207
|
+
pause: pause
|
|
196
208
|
}));
|
|
197
209
|
};
|
|
198
210
|
|
|
@@ -93,10 +93,8 @@ var ComicComponent = function ComicComponent(_ref) {
|
|
|
93
93
|
setTransition('slide-animation');
|
|
94
94
|
setCount(slideCount + 1);
|
|
95
95
|
setStarted(true);
|
|
96
|
-
} else {
|
|
97
|
-
close();
|
|
98
96
|
}
|
|
99
|
-
}, [
|
|
97
|
+
}, [slideCount, slides === null || slides === void 0 ? void 0 : slides.length]);
|
|
100
98
|
var goToPreviousSlide = (0, _react.useCallback)(function () {
|
|
101
99
|
setStarted(false);
|
|
102
100
|
setAudioFailed(false);
|
|
@@ -126,6 +124,7 @@ var ComicComponent = function ComicComponent(_ref) {
|
|
|
126
124
|
voice: slides === null || slides === void 0 ? void 0 : (_slides$slideCount2 = slides[slideCount]) === null || _slides$slideCount2 === void 0 ? void 0 : _slides$slideCount2.voice,
|
|
127
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,
|
|
128
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,
|
|
129
128
|
started: started,
|
|
130
129
|
soundActions: soundActions,
|
|
131
130
|
emitEvent: emitEvent,
|
|
@@ -134,7 +133,7 @@ var ComicComponent = function ComicComponent(_ref) {
|
|
|
134
133
|
setAudioFailed(true);
|
|
135
134
|
},
|
|
136
135
|
onFinish: function onFinish() {
|
|
137
|
-
if (automatic) {
|
|
136
|
+
if (automatic && !(slide !== null && slide !== void 0 && slide.slideTimer)) {
|
|
138
137
|
goToNextSlide();
|
|
139
138
|
}
|
|
140
139
|
}
|
package/dist/components/conversational-pro-component/components/ConversationalProComponent.js
CHANGED
|
@@ -27,12 +27,22 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
27
27
|
|
|
28
28
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
29
29
|
|
|
30
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
31
|
+
|
|
30
32
|
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; }
|
|
31
33
|
|
|
32
34
|
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; }
|
|
33
35
|
|
|
34
36
|
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; }
|
|
35
37
|
|
|
38
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
39
|
+
|
|
40
|
+
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."); }
|
|
41
|
+
|
|
42
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
43
|
+
|
|
44
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
45
|
+
|
|
36
46
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
37
47
|
|
|
38
48
|
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."); }
|
|
@@ -49,9 +59,10 @@ var characterMs = 75;
|
|
|
49
59
|
var minMs = 1400;
|
|
50
60
|
|
|
51
61
|
var ConversationProViewer = function ConversationProViewer(_ref) {
|
|
52
|
-
var _background$img, _currentLineData$
|
|
62
|
+
var _background$img, _currentLineData$slot3, _currentMessage$text;
|
|
53
63
|
|
|
54
64
|
var emitEvent = _ref.emitEvent,
|
|
65
|
+
pause = _ref.pause,
|
|
55
66
|
lines = _ref.lines,
|
|
56
67
|
edges = _ref.edges,
|
|
57
68
|
characters = _ref.characters,
|
|
@@ -86,6 +97,11 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
|
|
|
86
97
|
currentLine = _useState10[0],
|
|
87
98
|
setCurrentLine = _useState10[1];
|
|
88
99
|
|
|
100
|
+
var _useState11 = (0, _react.useState)(false),
|
|
101
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
|
102
|
+
ttsStarted = _useState12[0],
|
|
103
|
+
setTTsStart = _useState12[1];
|
|
104
|
+
|
|
89
105
|
var _soundActions = _slicedToArray(soundActions, 1),
|
|
90
106
|
playSound = _soundActions[0];
|
|
91
107
|
|
|
@@ -95,19 +111,43 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
|
|
|
95
111
|
|
|
96
112
|
var backgroundImage = (background === null || background === void 0 ? void 0 : (_background$img = background.img) === null || _background$img === void 0 ? void 0 : _background$img.url) || null;
|
|
97
113
|
var currentLineData = lines[currentLine];
|
|
98
|
-
var voiceOverSlots = [];
|
|
99
114
|
var voiceOver = currentLineData.voiceOver,
|
|
100
115
|
decision = currentLineData.decision;
|
|
116
|
+
var voiceOverSlots = [];
|
|
101
117
|
var isBranched = !!edges;
|
|
102
|
-
|
|
103
|
-
var _useState11 = (0, _react.useState)(false),
|
|
104
|
-
_useState12 = _slicedToArray(_useState11, 2),
|
|
105
|
-
previousLineWasDecision = _useState12[0],
|
|
106
|
-
setPreviousLineWasDecision = _useState12[1];
|
|
107
|
-
|
|
108
118
|
var isVoiceOver = voiceOver || currentLineData.type === 'conversationalNarration';
|
|
109
119
|
var isDecision = decision || currentLineData.type === 'conversationalDecision';
|
|
110
120
|
var isFlex = currentLineData.flex;
|
|
121
|
+
|
|
122
|
+
var _useState13 = (0, _react.useState)([]),
|
|
123
|
+
_useState14 = _slicedToArray(_useState13, 2),
|
|
124
|
+
edgesHistory = _useState14[0],
|
|
125
|
+
setEdgesHistory = _useState14[1];
|
|
126
|
+
|
|
127
|
+
var lastNodeId = (0, _react.useMemo)(function () {
|
|
128
|
+
return edgesHistory[edgesHistory.length - 1];
|
|
129
|
+
}, [edgesHistory]);
|
|
130
|
+
var findLastLineBranched = (0, _react.useCallback)(function () {
|
|
131
|
+
var lastEdge = edges.find(function (edge) {
|
|
132
|
+
return edge.fromId === lastNodeId;
|
|
133
|
+
});
|
|
134
|
+
var lastLine = lines.find(function (line) {
|
|
135
|
+
return line.id === lastEdge.fromId;
|
|
136
|
+
});
|
|
137
|
+
return lastLine;
|
|
138
|
+
}, [edges, lines, lastNodeId]);
|
|
139
|
+
var previousLineWasDecision = (0, _react.useCallback)(function () {
|
|
140
|
+
if (isBranched) {
|
|
141
|
+
// if we have edges, we need to check if the previous line was a decision
|
|
142
|
+
var _lastLine = findLastLineBranched();
|
|
143
|
+
|
|
144
|
+
return _lastLine === null || _lastLine === void 0 ? void 0 : _lastLine.decision;
|
|
145
|
+
} // if there is no branching, the previous line is the previous one
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
var lastLine = lines[currentLine - 1] ? lines[currentLine - 1] : {};
|
|
149
|
+
return currentLine > 0 && (lastLine === null || lastLine === void 0 ? void 0 : lastLine.decision);
|
|
150
|
+
}, [isBranched, findLastLineBranched, lines, currentLine]);
|
|
111
151
|
var translate = (0, _react.useCallback)(function (id) {
|
|
112
152
|
return emitEvent({
|
|
113
153
|
type: 'translate',
|
|
@@ -115,11 +155,13 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
|
|
|
115
155
|
});
|
|
116
156
|
}, [emitEvent]);
|
|
117
157
|
var getCurrentMessage = (0, _react.useCallback)(function () {
|
|
158
|
+
var _currentLineData$slot, _currentLineData$slot2;
|
|
159
|
+
|
|
118
160
|
if (isVoiceOver) {
|
|
119
161
|
return currentLineData;
|
|
120
162
|
}
|
|
121
163
|
|
|
122
|
-
var currentMessage = currentLineData.slots.find(function (slot) {
|
|
164
|
+
var currentMessage = currentLineData === null || currentLineData === void 0 ? void 0 : (_currentLineData$slot = currentLineData.slots) === null || _currentLineData$slot === void 0 ? void 0 : _currentLineData$slot.find(function (slot) {
|
|
123
165
|
return slot.uid && slot.talking;
|
|
124
166
|
});
|
|
125
167
|
|
|
@@ -128,21 +170,30 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
|
|
|
128
170
|
} // Old conversational schema
|
|
129
171
|
|
|
130
172
|
|
|
131
|
-
return currentLineData.slots.find(function (slot) {
|
|
173
|
+
return currentLineData === null || currentLineData === void 0 ? void 0 : (_currentLineData$slot2 = currentLineData.slots) === null || _currentLineData$slot2 === void 0 ? void 0 : _currentLineData$slot2.find(function (slot) {
|
|
132
174
|
return slot.uid && slot.text;
|
|
133
175
|
});
|
|
134
176
|
}, [currentLineData, isVoiceOver]);
|
|
135
177
|
var currentMessage = (0, _react.useMemo)(function () {
|
|
136
178
|
return !isDecision ? getCurrentMessage() : {};
|
|
137
|
-
}, [getCurrentMessage, isDecision]);
|
|
179
|
+
}, [getCurrentMessage, isDecision]);
|
|
180
|
+
var listProps = {
|
|
181
|
+
characters: currentCharacters,
|
|
182
|
+
lodSettings: lodSettings,
|
|
183
|
+
actors: actors,
|
|
184
|
+
currentMessage: currentMessage || {},
|
|
185
|
+
slots: !isVoiceOver ? currentLineData.slots : voiceOverSlots,
|
|
186
|
+
flex: isFlex,
|
|
187
|
+
pause: pause
|
|
188
|
+
}; // Recupera la antigua linea de la conversacion para conservar los personajes en voice-over
|
|
138
189
|
|
|
139
190
|
var leftWithSlots = lines.slice(0, currentLine + 1).reverse().find(function (line) {
|
|
140
191
|
return line.slots;
|
|
141
192
|
});
|
|
142
|
-
var
|
|
143
|
-
var hasCharacters = !isDecision && ((_currentLineData$slot = currentLineData.slots) === null || _currentLineData$slot === void 0 ? void 0 : _currentLineData$slot.filter(function (slot) {
|
|
193
|
+
var hasCharacters = !isDecision && ((_currentLineData$slot3 = currentLineData.slots) === null || _currentLineData$slot3 === void 0 ? void 0 : _currentLineData$slot3.filter(function (slot) {
|
|
144
194
|
return slot.uid;
|
|
145
195
|
}).length);
|
|
196
|
+
var autoPlayTime = characterMs * ((currentMessage === null || currentMessage === void 0 ? void 0 : (_currentMessage$text = currentMessage.text) === null || _currentMessage$text === void 0 ? void 0 : _currentMessage$text.length) || 0);
|
|
146
197
|
var currentSlots = [];
|
|
147
198
|
|
|
148
199
|
if (currentLineData.slots) {
|
|
@@ -202,14 +253,6 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
|
|
|
202
253
|
}
|
|
203
254
|
}
|
|
204
255
|
|
|
205
|
-
var listProps = {
|
|
206
|
-
characters: currentCharacters,
|
|
207
|
-
lodSettings: lodSettings,
|
|
208
|
-
actors: actors,
|
|
209
|
-
currentMessage: currentMessage || {},
|
|
210
|
-
slots: !isVoiceOver ? currentLineData.slots : voiceOverSlots,
|
|
211
|
-
flex: isFlex
|
|
212
|
-
};
|
|
213
256
|
var finishConversation = (0, _react.useCallback)(function () {
|
|
214
257
|
emitEvent({
|
|
215
258
|
type: 'success'
|
|
@@ -243,27 +286,36 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
|
|
|
243
286
|
var handleBranchDirection = (0, _react.useCallback)(function () {
|
|
244
287
|
var forward = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
245
288
|
var keys = forward ? ['fromId', 'toId'] : ['toId', 'fromId'];
|
|
246
|
-
var
|
|
289
|
+
var foundEdges = edges.filter(function (edge) {
|
|
247
290
|
return edge[keys[0]] === currentLineData.id;
|
|
248
291
|
});
|
|
292
|
+
var foundEdge = foundEdges.length === 1 ? foundEdges[0] : foundEdges.find(function (edge) {
|
|
293
|
+
return edge[keys[1]] === lastNodeId;
|
|
294
|
+
});
|
|
249
295
|
|
|
250
296
|
if (!(foundEdge !== null && foundEdge !== void 0 && foundEdge[keys[0]])) {
|
|
251
|
-
|
|
252
|
-
}
|
|
253
|
-
var destination = lines.findIndex(function (line) {
|
|
254
|
-
return line.id === foundEdge[keys[1]];
|
|
255
|
-
});
|
|
297
|
+
return;
|
|
298
|
+
} // if going backwards, we need to remove the last node from the history
|
|
256
299
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
finishConversation();
|
|
261
|
-
}
|
|
300
|
+
|
|
301
|
+
if (!forward) {
|
|
302
|
+
setEdgesHistory(edgesHistory.slice(0, -1));
|
|
262
303
|
}
|
|
263
|
-
|
|
304
|
+
|
|
305
|
+
var destination = lines.findIndex(function (line) {
|
|
306
|
+
return line.id === foundEdge[keys[1]];
|
|
307
|
+
});
|
|
308
|
+
|
|
309
|
+
if (destination >= 0) {
|
|
310
|
+
setCurrentLine(destination);
|
|
311
|
+
} else {
|
|
312
|
+
finishConversation();
|
|
313
|
+
}
|
|
314
|
+
}, [currentLineData.id, edges, edgesHistory, finishConversation, lastNodeId, lines]);
|
|
264
315
|
var handleClickNext = (0, _react.useCallback)(function (choice, reset) {
|
|
265
316
|
var isLast = false;
|
|
266
|
-
|
|
317
|
+
setTTsStart(false);
|
|
318
|
+
setEdgesHistory([].concat(_toConsumableArray(edgesHistory), [currentLineData.id]));
|
|
267
319
|
setStarted(false);
|
|
268
320
|
setAudioFailed(false);
|
|
269
321
|
|
|
@@ -279,34 +331,51 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
|
|
|
279
331
|
|
|
280
332
|
if (line + 1 <= maxLine) {
|
|
281
333
|
setCurrentLine(line + 1);
|
|
334
|
+
} else if (currentLineData.decision) {
|
|
335
|
+
finishConversation();
|
|
282
336
|
} else {
|
|
283
337
|
isLast = true;
|
|
284
|
-
finishConversation();
|
|
285
338
|
}
|
|
286
339
|
}
|
|
287
340
|
|
|
288
341
|
if (!isLast) {
|
|
289
342
|
setStarted(true);
|
|
290
343
|
}
|
|
291
|
-
}, [currentLine, currentLineData
|
|
344
|
+
}, [currentLine, currentLineData.decision, currentLineData.id, finishConversation, handleBranchDirection, handleDecisionBranch, isBranched, lines.length, edgesHistory]);
|
|
292
345
|
|
|
293
346
|
var handleClickBack = function handleClickBack() {
|
|
294
347
|
setStarted(false);
|
|
348
|
+
setTTsStart(false);
|
|
295
349
|
setAudioFailed(false);
|
|
296
350
|
|
|
297
351
|
if (isBranched) {
|
|
298
352
|
handleBranchDirection(false);
|
|
299
|
-
} else if (
|
|
353
|
+
} else if (!previousLineWasDecision()) {
|
|
300
354
|
setCurrentLine(currentLine - 1);
|
|
301
355
|
}
|
|
302
356
|
|
|
303
357
|
setStarted(true);
|
|
304
358
|
};
|
|
305
359
|
|
|
360
|
+
var isEndNode = (0, _react.useCallback)(function () {
|
|
361
|
+
if (isBranched) {
|
|
362
|
+
return currentLineData && currentLineData.type !== 'conversationalDecision' && !edges.find(function (edge) {
|
|
363
|
+
return edge.fromId === currentLineData.id;
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
return currentLine === lines.length - 1;
|
|
368
|
+
}, [currentLine, currentLineData, edges, isBranched, lines.length]);
|
|
369
|
+
|
|
306
370
|
var manualClickNext = function manualClickNext() {
|
|
307
371
|
playSound('click-ui');
|
|
308
|
-
|
|
309
|
-
|
|
372
|
+
|
|
373
|
+
if (isEndNode()) {
|
|
374
|
+
finishConversation();
|
|
375
|
+
} else {
|
|
376
|
+
setAutomatic(false);
|
|
377
|
+
handleClickNext();
|
|
378
|
+
}
|
|
310
379
|
};
|
|
311
380
|
|
|
312
381
|
var manualClickBack = function manualClickBack() {
|
|
@@ -315,39 +384,67 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
|
|
|
315
384
|
handleClickBack();
|
|
316
385
|
};
|
|
317
386
|
|
|
318
|
-
var autoplayCond = automatic && !isDecision;
|
|
319
|
-
var disableBackButton =
|
|
387
|
+
var autoplayCond = automatic && !isDecision && !pause;
|
|
388
|
+
var disableBackButton = (0, _react.useMemo)(function () {
|
|
389
|
+
return currentLine === 0 || previousLineWasDecision();
|
|
390
|
+
}, [currentLine, previousLineWasDecision]);
|
|
320
391
|
(0, _useEkho.default)({
|
|
321
392
|
audioType: currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.audioType,
|
|
322
393
|
volume: currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.audioVolume,
|
|
323
394
|
voice: currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.voice,
|
|
324
395
|
started: started,
|
|
396
|
+
slide: currentLine,
|
|
325
397
|
text: currentMessage === null || currentMessage === void 0 ? void 0 : currentMessage.text,
|
|
326
398
|
audio: currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.audio,
|
|
327
399
|
soundActions: soundActions,
|
|
328
400
|
emitEvent: emitEvent,
|
|
401
|
+
pauseTTS: pause,
|
|
402
|
+
onStart: function onStart() {
|
|
403
|
+
var _currentMessage$emoti;
|
|
404
|
+
|
|
405
|
+
if (currentMessage !== null && currentMessage !== void 0 && (_currentMessage$emoti = currentMessage.emotion) !== null && _currentMessage$emoti !== void 0 && _currentMessage$emoti.includes('think')) return;
|
|
406
|
+
setTTsStart(true);
|
|
407
|
+
},
|
|
329
408
|
onError: function onError() {
|
|
330
409
|
setAudioFailed(true);
|
|
331
410
|
},
|
|
332
411
|
onFinish: function onFinish() {
|
|
412
|
+
setTTsStart(false);
|
|
413
|
+
|
|
333
414
|
if (autoplayCond) {
|
|
334
415
|
handleClickNext();
|
|
335
416
|
}
|
|
336
417
|
}
|
|
337
|
-
});
|
|
418
|
+
});
|
|
419
|
+
(0, _react.useEffect)(function () {
|
|
420
|
+
var _currentMessage$emoti2;
|
|
421
|
+
|
|
422
|
+
var timeout;
|
|
423
|
+
|
|
424
|
+
if (((currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.audioType) === 'none' || audioFailed) && !(currentMessage !== null && currentMessage !== void 0 && (_currentMessage$emoti2 = currentMessage.emotion) !== null && _currentMessage$emoti2 !== void 0 && _currentMessage$emoti2.includes('think'))) {
|
|
425
|
+
setTTsStart(true);
|
|
426
|
+
timeout = setTimeout(function () {
|
|
427
|
+
setTTsStart(false);
|
|
428
|
+
}, autoPlayTime < minMs ? minMs : autoPlayTime);
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
return function () {
|
|
432
|
+
if (timeout) clearTimeout(timeout);
|
|
433
|
+
};
|
|
434
|
+
}, [audioFailed, currentLineData, currentMessage === null || currentMessage === void 0 ? void 0 : currentMessage.emotion, autoPlayTime]); // Autoplay logic
|
|
338
435
|
|
|
339
436
|
(0, _react.useEffect)(function () {
|
|
340
437
|
if (autoplayCond && ((currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.audioType) === 'none' || audioFailed)) {
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
438
|
+
// if it's not last node
|
|
439
|
+
if (!isEndNode()) {
|
|
440
|
+
start(handleClickNext, autoPlayTime < minMs ? minMs : autoPlayTime);
|
|
441
|
+
}
|
|
345
442
|
}
|
|
346
443
|
|
|
347
444
|
return function () {
|
|
348
445
|
stop();
|
|
349
446
|
};
|
|
350
|
-
}, [currentMessage, start, stop, handleClickNext, currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.audioType, autoplayCond, audioFailed, lines]); // Calculate start node
|
|
447
|
+
}, [currentMessage, start, stop, handleClickNext, currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.audioType, autoplayCond, audioFailed, lines, isEndNode, autoPlayTime]); // Calculate start node
|
|
351
448
|
|
|
352
449
|
(0, _react.useEffect)(function () {
|
|
353
450
|
if (isBranched && !mounted) {
|
|
@@ -394,7 +491,9 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
|
|
|
394
491
|
style: backgroundImage ? {
|
|
395
492
|
backgroundImage: "url(\"".concat(backgroundImage, "\")")
|
|
396
493
|
} : null
|
|
397
|
-
}, /*#__PURE__*/_react.default.createElement(_SlotList.default,
|
|
494
|
+
}, /*#__PURE__*/_react.default.createElement(_SlotList.default, _extends({}, listProps, {
|
|
495
|
+
ttsStarted: ttsStarted
|
|
496
|
+
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
398
497
|
className: "conversation--body",
|
|
399
498
|
dir: "auto"
|
|
400
499
|
}, currentMessage ? /*#__PURE__*/_react.default.createElement(_Message.default, {
|
|
@@ -410,7 +509,7 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
|
|
|
410
509
|
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
411
510
|
className: (0, _LangIsRtl.default)() ? 'icon-next' : 'icon-back'
|
|
412
511
|
})), /*#__PURE__*/_react.default.createElement("button", {
|
|
413
|
-
className: "gat--btn__round",
|
|
512
|
+
className: "gat--btn__round ".concat(automatic && isEndNode() ? 'glowing-animation' : ''),
|
|
414
513
|
type: "button",
|
|
415
514
|
onClick: manualClickNext
|
|
416
515
|
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
@@ -25,10 +25,12 @@ var SlotList = function SlotList(_ref) {
|
|
|
25
25
|
var characters = _ref.characters,
|
|
26
26
|
actors = _ref.actors,
|
|
27
27
|
lodSettings = _ref.lodSettings,
|
|
28
|
+
ttsStarted = _ref.ttsStarted,
|
|
28
29
|
currentMessage = _ref.currentMessage,
|
|
29
30
|
flex = _ref.flex,
|
|
30
31
|
slots = _ref.slots,
|
|
31
|
-
children = _ref.children
|
|
32
|
+
children = _ref.children,
|
|
33
|
+
pause = _ref.pause;
|
|
32
34
|
|
|
33
35
|
var characterProps = function characterProps(_ref2) {
|
|
34
36
|
var character = _ref2.character,
|
|
@@ -142,7 +144,9 @@ var SlotList = function SlotList(_ref) {
|
|
|
142
144
|
slots: slots,
|
|
143
145
|
flex: flex,
|
|
144
146
|
currentMessage: currentMessage,
|
|
145
|
-
lodSettings: lodSettings
|
|
147
|
+
lodSettings: lodSettings,
|
|
148
|
+
ttsStarted: ttsStarted,
|
|
149
|
+
pause: pause
|
|
146
150
|
}), children || /*#__PURE__*/_react.default.createElement(Slots, null));
|
|
147
151
|
};
|
|
148
152
|
|