@gamelearn/arcade-components 2.2.1 → 2.2.3
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 +2 -4
- package/dist/components/cards-selector-puzzle-component/components/CardsSelectorPuzzleComponent.js +3 -6
- package/dist/components/chained-image-click-puzzle-component/components/CurrentImagePuzzle.js +8 -20
- package/dist/components/comic-component/components/ComicComponent.js +4 -2
- package/dist/components/conversational-pro-component/components/ConversationalProComponent.js +48 -144
- package/dist/components/conversational-pro-component/components/SlotList.js +2 -6
- package/dist/components/conversational-pro-component/components/scene/Panel.js +10 -72
- package/dist/components/conversational-pro-component/components/scene/Panels.js +1 -3
- package/dist/components/conversational-pro-component/components/scene/index.js +1 -8
- package/dist/components/dialog-component/components/DialogComponent.js +81 -202
- package/dist/components/feedback-component/components/FeedbackComponent.js +3 -2
- package/dist/components/frame-click-puzzle-component/components/CurrentFramePuzzle.js +3 -16
- package/dist/components/frame-click-puzzle-component/components/FrameClickPuzzleComponent.js +2 -4
- package/dist/components/image-click-wrapper-component/components/ImageClickWrapperComponent.js +1 -9
- package/dist/components/lectures-component/components/LecturesComponent.js +1 -1
- package/dist/components/survey-component/components/SurveyComponent.js +2 -4
- package/dist/components/terminal-puzzle-component/components/Visor/index.js +1 -1
- package/dist/components/test-component/components/Container.js +3 -4
- package/dist/components/test-component/components/TestComponent.js +4 -11
- package/dist/helpers/index.js +4 -70
- package/dist/helpers/useEkho.js +8 -14
- package/package.json +2 -2
|
@@ -106,9 +106,7 @@ var AutoEvaluation = function AutoEvaluation(_ref) {
|
|
|
106
106
|
}
|
|
107
107
|
};
|
|
108
108
|
|
|
109
|
-
return /*#__PURE__*/_react.default.createElement(
|
|
110
|
-
className: "test--container__overlay"
|
|
111
|
-
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
109
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
112
110
|
className: "test--container",
|
|
113
111
|
dir: "auto"
|
|
114
112
|
}, phase === 'start' && /*#__PURE__*/_react.default.createElement(_StartScreen.default, {
|
|
@@ -159,7 +157,7 @@ var AutoEvaluation = function AutoEvaluation(_ref) {
|
|
|
159
157
|
})))), phase === 'end' && /*#__PURE__*/_react.default.createElement(_EndScreen.default, {
|
|
160
158
|
onFinish: close,
|
|
161
159
|
translate: translate
|
|
162
|
-
}))
|
|
160
|
+
}));
|
|
163
161
|
};
|
|
164
162
|
|
|
165
163
|
var _default = AutoEvaluation;
|
package/dist/components/cards-selector-puzzle-component/components/CardsSelectorPuzzleComponent.js
CHANGED
|
@@ -142,11 +142,6 @@ 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
|
-
}
|
|
150
145
|
};
|
|
151
146
|
|
|
152
147
|
var handleFeedbackFuncionOnClose = function handleFeedbackFuncionOnClose() {
|
|
@@ -175,11 +170,13 @@ var CardsSelectorPuzzleComponent = function CardsSelectorPuzzleComponent(_ref) {
|
|
|
175
170
|
|
|
176
171
|
if (pickedCard !== null && pickedCard !== void 0 && pickedCard.desc) {
|
|
177
172
|
setFeedBackText(pickedCard.desc);
|
|
178
|
-
setFeedbackIsShown(true);
|
|
179
173
|
}
|
|
174
|
+
} else if (info.solution.right.desc) {
|
|
175
|
+
setFeedBackText(info.solution.right.desc);
|
|
180
176
|
}
|
|
181
177
|
|
|
182
178
|
playSound('score');
|
|
179
|
+
setFeedbackIsShown(true);
|
|
183
180
|
emitEvent({
|
|
184
181
|
type: 'hidePuzzleButtons',
|
|
185
182
|
payload: true
|
package/dist/components/chained-image-click-puzzle-component/components/CurrentImagePuzzle.js
CHANGED
|
@@ -46,8 +46,6 @@ 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
|
-
|
|
51
49
|
var list = _ref.list,
|
|
52
50
|
description = _ref.description,
|
|
53
51
|
nodeId = _ref.nodeId,
|
|
@@ -57,11 +55,9 @@ var CurrentImageClickPuzzle = function CurrentImageClickPuzzle(_ref) {
|
|
|
57
55
|
setResolveAction = _ref.setResolveAction,
|
|
58
56
|
soundActions = _ref.soundActions,
|
|
59
57
|
setSelected = _ref.setSelected,
|
|
60
|
-
selected = _ref.selected
|
|
61
|
-
pause = _ref.pause;
|
|
58
|
+
selected = _ref.selected;
|
|
62
59
|
var accRewards = (0, _react.useRef)([]);
|
|
63
60
|
var correctClicked = (0, _react.useRef)(0);
|
|
64
|
-
var currentSelected = (0, _react.useRef)(0);
|
|
65
61
|
|
|
66
62
|
var _useState = (0, _react.useState)(0),
|
|
67
63
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -107,7 +103,6 @@ var CurrentImageClickPuzzle = function CurrentImageClickPuzzle(_ref) {
|
|
|
107
103
|
info.description = description;
|
|
108
104
|
(0, _react.useEffect)(function () {
|
|
109
105
|
correctClicked.current = 0;
|
|
110
|
-
currentSelected.current = 0;
|
|
111
106
|
}, [index]);
|
|
112
107
|
var onComplete = (0, _react.useCallback)(function (rw) {
|
|
113
108
|
var correct = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
@@ -119,14 +114,7 @@ var CurrentImageClickPuzzle = function CurrentImageClickPuzzle(_ref) {
|
|
|
119
114
|
if (specificFeedbacks !== null && specificFeedbacks !== void 0 && (_specificFeedbacks$co = specificFeedbacks.correctFeedbacks) !== null && _specificFeedbacks$co !== void 0 && _specificFeedbacks$co.length && !currentImageProps.hasClickOnce && !finish) {
|
|
120
115
|
correctClicked.current += 1;
|
|
121
116
|
} else {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
if (currentSelected.current) {
|
|
125
|
-
total -= currentSelected.current;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
correctClicked.current = currentImageProps.areas.length;
|
|
129
|
-
setSelected(total + correctClicked.current);
|
|
117
|
+
correctClicked.current += currentImageProps.areas.length;
|
|
130
118
|
}
|
|
131
119
|
|
|
132
120
|
if (correctClicked.current === currentImageProps.areas.length) {
|
|
@@ -154,7 +142,7 @@ var CurrentImageClickPuzzle = function CurrentImageClickPuzzle(_ref) {
|
|
|
154
142
|
type: 'failPuzzle'
|
|
155
143
|
});
|
|
156
144
|
}
|
|
157
|
-
}, [
|
|
145
|
+
}, [index, list.length, currentImageProps.hasClickOrder, currentImageProps.hasClickOnce, currentImageProps.areas.length, handleFinish, specificFeedbacks, setSelected, selected, emitEvent]);
|
|
158
146
|
|
|
159
147
|
var onResolve = function onResolve() {
|
|
160
148
|
playSound('score');
|
|
@@ -180,11 +168,12 @@ var CurrentImageClickPuzzle = function CurrentImageClickPuzzle(_ref) {
|
|
|
180
168
|
resolvedItems.current[puzzleId] = true;
|
|
181
169
|
}
|
|
182
170
|
}, [onComplete, puzzleId, currentPuzzleStatus]);
|
|
183
|
-
|
|
171
|
+
|
|
172
|
+
var checkSelectedAreas = function checkSelectedAreas() {
|
|
184
173
|
var areasSelected = currentImageProps.hasClickOnce ? currentImageProps.areas.length : 1;
|
|
185
|
-
currentSelected.current += areasSelected;
|
|
186
174
|
setSelected(selected + areasSelected);
|
|
187
|
-
}
|
|
175
|
+
};
|
|
176
|
+
|
|
188
177
|
return /*#__PURE__*/_react.default.createElement(_imageClickWrapperComponent.default, _extends({
|
|
189
178
|
key: index
|
|
190
179
|
}, currentImageProps, {
|
|
@@ -203,8 +192,7 @@ var CurrentImageClickPuzzle = function CurrentImageClickPuzzle(_ref) {
|
|
|
203
192
|
emitEvent: emitEvent,
|
|
204
193
|
disableExit: disableExit,
|
|
205
194
|
soundActions: soundActions,
|
|
206
|
-
setResolveAction: setResolveAction
|
|
207
|
-
pause: pause
|
|
195
|
+
setResolveAction: setResolveAction
|
|
208
196
|
}));
|
|
209
197
|
};
|
|
210
198
|
|
|
@@ -93,8 +93,10 @@ var ComicComponent = function ComicComponent(_ref) {
|
|
|
93
93
|
setTransition('slide-animation');
|
|
94
94
|
setCount(slideCount + 1);
|
|
95
95
|
setStarted(true);
|
|
96
|
+
} else {
|
|
97
|
+
close();
|
|
96
98
|
}
|
|
97
|
-
}, [slideCount, slides === null || slides === void 0 ? void 0 : slides.length]);
|
|
99
|
+
}, [close, slideCount, slides === null || slides === void 0 ? void 0 : slides.length]);
|
|
98
100
|
var goToPreviousSlide = (0, _react.useCallback)(function () {
|
|
99
101
|
setStarted(false);
|
|
100
102
|
setAudioFailed(false);
|
|
@@ -132,7 +134,7 @@ var ComicComponent = function ComicComponent(_ref) {
|
|
|
132
134
|
setAudioFailed(true);
|
|
133
135
|
},
|
|
134
136
|
onFinish: function onFinish() {
|
|
135
|
-
if (automatic
|
|
137
|
+
if (automatic) {
|
|
136
138
|
goToNextSlide();
|
|
137
139
|
}
|
|
138
140
|
}
|
package/dist/components/conversational-pro-component/components/ConversationalProComponent.js
CHANGED
|
@@ -27,22 +27,12 @@ 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
|
-
|
|
32
30
|
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; }
|
|
33
31
|
|
|
34
32
|
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; }
|
|
35
33
|
|
|
36
34
|
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; }
|
|
37
35
|
|
|
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
|
-
|
|
46
36
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
47
37
|
|
|
48
38
|
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."); }
|
|
@@ -59,10 +49,9 @@ var characterMs = 75;
|
|
|
59
49
|
var minMs = 1400;
|
|
60
50
|
|
|
61
51
|
var ConversationProViewer = function ConversationProViewer(_ref) {
|
|
62
|
-
var _background$img, _currentLineData$
|
|
52
|
+
var _background$img, _currentLineData$slot;
|
|
63
53
|
|
|
64
54
|
var emitEvent = _ref.emitEvent,
|
|
65
|
-
pause = _ref.pause,
|
|
66
55
|
lines = _ref.lines,
|
|
67
56
|
edges = _ref.edges,
|
|
68
57
|
characters = _ref.characters,
|
|
@@ -97,11 +86,6 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
|
|
|
97
86
|
currentLine = _useState10[0],
|
|
98
87
|
setCurrentLine = _useState10[1];
|
|
99
88
|
|
|
100
|
-
var _useState11 = (0, _react.useState)(false),
|
|
101
|
-
_useState12 = _slicedToArray(_useState11, 2),
|
|
102
|
-
ttsStarted = _useState12[0],
|
|
103
|
-
setTTsStart = _useState12[1];
|
|
104
|
-
|
|
105
89
|
var _soundActions = _slicedToArray(soundActions, 1),
|
|
106
90
|
playSound = _soundActions[0];
|
|
107
91
|
|
|
@@ -111,43 +95,19 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
|
|
|
111
95
|
|
|
112
96
|
var backgroundImage = (background === null || background === void 0 ? void 0 : (_background$img = background.img) === null || _background$img === void 0 ? void 0 : _background$img.url) || null;
|
|
113
97
|
var currentLineData = lines[currentLine];
|
|
98
|
+
var voiceOverSlots = [];
|
|
114
99
|
var voiceOver = currentLineData.voiceOver,
|
|
115
100
|
decision = currentLineData.decision;
|
|
116
|
-
var voiceOverSlots = [];
|
|
117
101
|
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
|
+
|
|
118
108
|
var isVoiceOver = voiceOver || currentLineData.type === 'conversationalNarration';
|
|
119
109
|
var isDecision = decision || currentLineData.type === 'conversationalDecision';
|
|
120
110
|
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]);
|
|
151
111
|
var translate = (0, _react.useCallback)(function (id) {
|
|
152
112
|
return emitEvent({
|
|
153
113
|
type: 'translate',
|
|
@@ -155,13 +115,11 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
|
|
|
155
115
|
});
|
|
156
116
|
}, [emitEvent]);
|
|
157
117
|
var getCurrentMessage = (0, _react.useCallback)(function () {
|
|
158
|
-
var _currentLineData$slot, _currentLineData$slot2;
|
|
159
|
-
|
|
160
118
|
if (isVoiceOver) {
|
|
161
119
|
return currentLineData;
|
|
162
120
|
}
|
|
163
121
|
|
|
164
|
-
var currentMessage = currentLineData
|
|
122
|
+
var currentMessage = currentLineData.slots.find(function (slot) {
|
|
165
123
|
return slot.uid && slot.talking;
|
|
166
124
|
});
|
|
167
125
|
|
|
@@ -170,30 +128,21 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
|
|
|
170
128
|
} // Old conversational schema
|
|
171
129
|
|
|
172
130
|
|
|
173
|
-
return currentLineData
|
|
131
|
+
return currentLineData.slots.find(function (slot) {
|
|
174
132
|
return slot.uid && slot.text;
|
|
175
133
|
});
|
|
176
134
|
}, [currentLineData, isVoiceOver]);
|
|
177
135
|
var currentMessage = (0, _react.useMemo)(function () {
|
|
178
136
|
return !isDecision ? getCurrentMessage() : {};
|
|
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
|
|
137
|
+
}, [getCurrentMessage, isDecision]); // Recupera la antigua linea de la conversacion para conservar los personajes en voice-over
|
|
189
138
|
|
|
190
139
|
var leftWithSlots = lines.slice(0, currentLine + 1).reverse().find(function (line) {
|
|
191
140
|
return line.slots;
|
|
192
141
|
});
|
|
193
|
-
var
|
|
142
|
+
var lastLine = lines[currentLine - 1] ? lines[currentLine - 1] : {};
|
|
143
|
+
var hasCharacters = !isDecision && ((_currentLineData$slot = currentLineData.slots) === null || _currentLineData$slot === void 0 ? void 0 : _currentLineData$slot.filter(function (slot) {
|
|
194
144
|
return slot.uid;
|
|
195
145
|
}).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);
|
|
197
146
|
var currentSlots = [];
|
|
198
147
|
|
|
199
148
|
if (currentLineData.slots) {
|
|
@@ -253,6 +202,14 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
|
|
|
253
202
|
}
|
|
254
203
|
}
|
|
255
204
|
|
|
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
|
+
};
|
|
256
213
|
var finishConversation = (0, _react.useCallback)(function () {
|
|
257
214
|
emitEvent({
|
|
258
215
|
type: 'success'
|
|
@@ -286,36 +243,27 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
|
|
|
286
243
|
var handleBranchDirection = (0, _react.useCallback)(function () {
|
|
287
244
|
var forward = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
288
245
|
var keys = forward ? ['fromId', 'toId'] : ['toId', 'fromId'];
|
|
289
|
-
var
|
|
246
|
+
var foundEdge = edges.find(function (edge) {
|
|
290
247
|
return edge[keys[0]] === currentLineData.id;
|
|
291
248
|
});
|
|
292
|
-
var foundEdge = foundEdges.length === 1 ? foundEdges[0] : foundEdges.find(function (edge) {
|
|
293
|
-
return edge[keys[1]] === lastNodeId;
|
|
294
|
-
});
|
|
295
249
|
|
|
296
250
|
if (!(foundEdge !== null && foundEdge !== void 0 && foundEdge[keys[0]])) {
|
|
297
|
-
return;
|
|
298
|
-
} // if going backwards, we need to remove the last node from the history
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
if (!forward) {
|
|
302
|
-
setEdgesHistory(edgesHistory.slice(0, -1));
|
|
303
|
-
}
|
|
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
251
|
finishConversation();
|
|
252
|
+
} else {
|
|
253
|
+
var destination = lines.findIndex(function (line) {
|
|
254
|
+
return line.id === foundEdge[keys[1]];
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
if (destination >= 0) {
|
|
258
|
+
setCurrentLine(destination);
|
|
259
|
+
} else {
|
|
260
|
+
finishConversation();
|
|
261
|
+
}
|
|
313
262
|
}
|
|
314
|
-
}, [currentLineData.id, edges,
|
|
263
|
+
}, [currentLineData.id, edges, finishConversation, lines]);
|
|
315
264
|
var handleClickNext = (0, _react.useCallback)(function (choice, reset) {
|
|
316
265
|
var isLast = false;
|
|
317
|
-
|
|
318
|
-
setEdgesHistory([].concat(_toConsumableArray(edgesHistory), [currentLineData.id]));
|
|
266
|
+
setPreviousLineWasDecision(currentLineData.decision);
|
|
319
267
|
setStarted(false);
|
|
320
268
|
setAudioFailed(false);
|
|
321
269
|
|
|
@@ -331,21 +279,19 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
|
|
|
331
279
|
|
|
332
280
|
if (line + 1 <= maxLine) {
|
|
333
281
|
setCurrentLine(line + 1);
|
|
334
|
-
} else if (currentLineData.decision) {
|
|
335
|
-
finishConversation();
|
|
336
282
|
} else {
|
|
337
283
|
isLast = true;
|
|
284
|
+
finishConversation();
|
|
338
285
|
}
|
|
339
286
|
}
|
|
340
287
|
|
|
341
288
|
if (!isLast) {
|
|
342
289
|
setStarted(true);
|
|
343
290
|
}
|
|
344
|
-
}, [currentLine, currentLineData
|
|
291
|
+
}, [currentLine, currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.decision, finishConversation, handleBranchDirection, handleDecisionBranch, isBranched, lines.length]);
|
|
345
292
|
|
|
346
293
|
var handleClickBack = function handleClickBack() {
|
|
347
294
|
setStarted(false);
|
|
348
|
-
setTTsStart(false);
|
|
349
295
|
setAudioFailed(false);
|
|
350
296
|
|
|
351
297
|
if (isBranched) {
|
|
@@ -357,25 +303,10 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
|
|
|
357
303
|
setStarted(true);
|
|
358
304
|
};
|
|
359
305
|
|
|
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
|
-
|
|
370
306
|
var manualClickNext = function manualClickNext() {
|
|
371
307
|
playSound('click-ui');
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
finishConversation();
|
|
375
|
-
} else {
|
|
376
|
-
setAutomatic(false);
|
|
377
|
-
handleClickNext();
|
|
378
|
-
}
|
|
308
|
+
setAutomatic(false);
|
|
309
|
+
handleClickNext();
|
|
379
310
|
};
|
|
380
311
|
|
|
381
312
|
var manualClickBack = function manualClickBack() {
|
|
@@ -384,8 +315,8 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
|
|
|
384
315
|
handleClickBack();
|
|
385
316
|
};
|
|
386
317
|
|
|
387
|
-
var autoplayCond = automatic && !isDecision
|
|
388
|
-
var disableBackButton = currentLine === 0 || previousLineWasDecision();
|
|
318
|
+
var autoplayCond = automatic && !isDecision;
|
|
319
|
+
var disableBackButton = currentLine === 0 || previousLineWasDecision || currentLine > 0 && (lastLine === null || lastLine === void 0 ? void 0 : lastLine.decision);
|
|
389
320
|
(0, _useEkho.default)({
|
|
390
321
|
audioType: currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.audioType,
|
|
391
322
|
volume: currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.audioVolume,
|
|
@@ -395,53 +326,28 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
|
|
|
395
326
|
audio: currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.audio,
|
|
396
327
|
soundActions: soundActions,
|
|
397
328
|
emitEvent: emitEvent,
|
|
398
|
-
pauseTTS: pause,
|
|
399
|
-
onStart: function onStart() {
|
|
400
|
-
var _currentMessage$emoti;
|
|
401
|
-
|
|
402
|
-
if (currentMessage !== null && currentMessage !== void 0 && (_currentMessage$emoti = currentMessage.emotion) !== null && _currentMessage$emoti !== void 0 && _currentMessage$emoti.includes('think')) return;
|
|
403
|
-
setTTsStart(true);
|
|
404
|
-
},
|
|
405
329
|
onError: function onError() {
|
|
406
330
|
setAudioFailed(true);
|
|
407
331
|
},
|
|
408
332
|
onFinish: function onFinish() {
|
|
409
|
-
setTTsStart(false);
|
|
410
|
-
|
|
411
333
|
if (autoplayCond) {
|
|
412
334
|
handleClickNext();
|
|
413
335
|
}
|
|
414
336
|
}
|
|
415
|
-
});
|
|
416
|
-
(0, _react.useEffect)(function () {
|
|
417
|
-
var _currentMessage$emoti2;
|
|
418
|
-
|
|
419
|
-
var timeout;
|
|
420
|
-
|
|
421
|
-
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'))) {
|
|
422
|
-
setTTsStart(true);
|
|
423
|
-
timeout = setTimeout(function () {
|
|
424
|
-
setTTsStart(false);
|
|
425
|
-
}, autoPlayTime < minMs ? minMs : autoPlayTime);
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
return function () {
|
|
429
|
-
if (timeout) clearTimeout(timeout);
|
|
430
|
-
};
|
|
431
|
-
}, [audioFailed, currentLineData, currentMessage === null || currentMessage === void 0 ? void 0 : currentMessage.emotion, autoPlayTime]); // Autoplay logic
|
|
337
|
+
}); // Autoplay logic
|
|
432
338
|
|
|
433
339
|
(0, _react.useEffect)(function () {
|
|
434
340
|
if (autoplayCond && ((currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.audioType) === 'none' || audioFailed)) {
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
341
|
+
var _currentMessage$text;
|
|
342
|
+
|
|
343
|
+
var time = characterMs * ((currentMessage === null || currentMessage === void 0 ? void 0 : (_currentMessage$text = currentMessage.text) === null || _currentMessage$text === void 0 ? void 0 : _currentMessage$text.length) || 0);
|
|
344
|
+
start(handleClickNext, time < minMs ? minMs : time);
|
|
439
345
|
}
|
|
440
346
|
|
|
441
347
|
return function () {
|
|
442
348
|
stop();
|
|
443
349
|
};
|
|
444
|
-
}, [currentMessage, start, stop, handleClickNext, currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.audioType, autoplayCond, audioFailed, lines
|
|
350
|
+
}, [currentMessage, start, stop, handleClickNext, currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.audioType, autoplayCond, audioFailed, lines]); // Calculate start node
|
|
445
351
|
|
|
446
352
|
(0, _react.useEffect)(function () {
|
|
447
353
|
if (isBranched && !mounted) {
|
|
@@ -488,9 +394,7 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
|
|
|
488
394
|
style: backgroundImage ? {
|
|
489
395
|
backgroundImage: "url(\"".concat(backgroundImage, "\")")
|
|
490
396
|
} : null
|
|
491
|
-
}, /*#__PURE__*/_react.default.createElement(_SlotList.default,
|
|
492
|
-
ttsStarted: ttsStarted
|
|
493
|
-
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
397
|
+
}, /*#__PURE__*/_react.default.createElement(_SlotList.default, listProps), /*#__PURE__*/_react.default.createElement("div", {
|
|
494
398
|
className: "conversation--body",
|
|
495
399
|
dir: "auto"
|
|
496
400
|
}, currentMessage ? /*#__PURE__*/_react.default.createElement(_Message.default, {
|
|
@@ -506,7 +410,7 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
|
|
|
506
410
|
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
507
411
|
className: (0, _LangIsRtl.default)() ? 'icon-next' : 'icon-back'
|
|
508
412
|
})), /*#__PURE__*/_react.default.createElement("button", {
|
|
509
|
-
className: "gat--btn__round
|
|
413
|
+
className: "gat--btn__round",
|
|
510
414
|
type: "button",
|
|
511
415
|
onClick: manualClickNext
|
|
512
416
|
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
@@ -25,12 +25,10 @@ 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,
|
|
29
28
|
currentMessage = _ref.currentMessage,
|
|
30
29
|
flex = _ref.flex,
|
|
31
30
|
slots = _ref.slots,
|
|
32
|
-
children = _ref.children
|
|
33
|
-
pause = _ref.pause;
|
|
31
|
+
children = _ref.children;
|
|
34
32
|
|
|
35
33
|
var characterProps = function characterProps(_ref2) {
|
|
36
34
|
var character = _ref2.character,
|
|
@@ -144,9 +142,7 @@ var SlotList = function SlotList(_ref) {
|
|
|
144
142
|
slots: slots,
|
|
145
143
|
flex: flex,
|
|
146
144
|
currentMessage: currentMessage,
|
|
147
|
-
lodSettings: lodSettings
|
|
148
|
-
ttsStarted: ttsStarted,
|
|
149
|
-
pause: pause
|
|
145
|
+
lodSettings: lodSettings
|
|
150
146
|
}), children || /*#__PURE__*/_react.default.createElement(Slots, null));
|
|
151
147
|
};
|
|
152
148
|
|
|
@@ -29,38 +29,17 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
29
29
|
|
|
30
30
|
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; }
|
|
31
31
|
|
|
32
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
33
|
-
|
|
34
|
-
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."); }
|
|
35
|
-
|
|
36
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
37
|
-
|
|
38
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
39
|
-
|
|
40
|
-
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
41
|
-
|
|
42
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
43
|
-
|
|
44
32
|
var isMobile = (0, _deviceDetection.DeviceDetection)();
|
|
45
33
|
var defaultCamPos = [0, 14.63, 16];
|
|
46
34
|
|
|
47
35
|
function Panel(_ref) {
|
|
48
|
-
var _character$resource4, _character$
|
|
36
|
+
var _character$resource4, _character$resource5;
|
|
49
37
|
|
|
50
38
|
var character = _ref.character,
|
|
51
|
-
ttsStarted = _ref.ttsStarted,
|
|
52
39
|
active = _ref.active;
|
|
53
40
|
var cameraRef = (0, _react.useRef)(null);
|
|
54
41
|
var sceneRef = (0, _react.useRef)(null);
|
|
55
42
|
var isCharacter = character.type === 'character';
|
|
56
|
-
|
|
57
|
-
var _useState = (0, _react.useState)(false),
|
|
58
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
59
|
-
talking = _useState2[0],
|
|
60
|
-
setTalking = _useState2[1];
|
|
61
|
-
|
|
62
|
-
var model = (0, _react.useRef)();
|
|
63
|
-
var defaultClip = (0, _react.useRef)();
|
|
64
43
|
var emotion = (0, _react.useMemo)(function () {
|
|
65
44
|
if (isCharacter) {
|
|
66
45
|
var _character$resource, _character$resource$a, _character$resource$a2, _character$resource3, _character$resource3$;
|
|
@@ -76,66 +55,26 @@ function Panel(_ref) {
|
|
|
76
55
|
|
|
77
56
|
return {};
|
|
78
57
|
}, [character.emotion, character === null || character === void 0 ? void 0 : (_character$resource4 = character.resource) === null || _character$resource4 === void 0 ? void 0 : _character$resource4.animations, isCharacter]);
|
|
79
|
-
var
|
|
80
|
-
var _model$current$userDa = model.current.userData,
|
|
81
|
-
mixer = _model$current$userDa.mixer,
|
|
82
|
-
defaultAnim = _model$current$userDa.defaultAnim,
|
|
83
|
-
emotionClip = _model$current$userDa.emotionClip;
|
|
84
|
-
|
|
85
|
-
if (defaultAnim && emotionClip) {
|
|
86
|
-
var emotionAction = mixer.clipAction(emotionClip, model.current);
|
|
87
|
-
var defaultAction = mixer.clipAction(defaultAnim, model.current);
|
|
88
|
-
mixer.stopAllAction();
|
|
89
|
-
(0, _helpers.executeCrossFade)(emotionAction, defaultAction);
|
|
90
|
-
setTalking(false);
|
|
91
|
-
}
|
|
92
|
-
}, []);
|
|
93
|
-
(0, _react.useEffect)(function () {
|
|
94
|
-
if (model.current) {
|
|
95
|
-
if (active) {
|
|
96
|
-
if (ttsStarted) {
|
|
97
|
-
var _character$resource5, _character$resource5$, _character$resource5$2;
|
|
98
|
-
|
|
99
|
-
(0, _helpers.executeTalkingAnimation)(model.current, character === null || character === void 0 ? void 0 : (_character$resource5 = character.resource) === null || _character$resource5 === void 0 ? void 0 : (_character$resource5$ = _character$resource5.animations) === null || _character$resource5$ === void 0 ? void 0 : (_character$resource5$2 = _character$resource5$.talking) === null || _character$resource5$2 === void 0 ? void 0 : _character$resource5$2.url);
|
|
100
|
-
setTalking(true);
|
|
101
|
-
} else {
|
|
102
|
-
resetAnimation();
|
|
103
|
-
}
|
|
104
|
-
} else if (talking) {
|
|
105
|
-
resetAnimation();
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}, [character === null || character === void 0 ? void 0 : (_character$resource6 = character.resource) === null || _character$resource6 === void 0 ? void 0 : (_character$resource6$ = _character$resource6.animations) === null || _character$resource6$ === void 0 ? void 0 : (_character$resource6$2 = _character$resource6$.talking) === null || _character$resource6$2 === void 0 ? void 0 : _character$resource6$2.url, ttsStarted, active, resetAnimation, talking]);
|
|
109
|
-
var onLoadElement = (0, _react.useCallback)(function (object) {
|
|
58
|
+
var onLoadElement = (0, _react.useCallback)(function (model) {
|
|
110
59
|
if (cameraRef.current) {
|
|
111
60
|
var boundingBox = new _three.Box3();
|
|
112
|
-
boundingBox.setFromObject(
|
|
61
|
+
boundingBox.setFromObject(model);
|
|
113
62
|
var size = boundingBox.getSize(new _three.Vector3());
|
|
114
63
|
cameraRef.current.position.fromArray(defaultCamPos);
|
|
115
64
|
cameraRef.current.rotation.set(0, 0, 0);
|
|
116
65
|
cameraRef.current.updateProjectionMatrix();
|
|
117
66
|
|
|
118
67
|
if (character.type === 'character') {
|
|
119
|
-
|
|
120
|
-
model.current = object;
|
|
121
|
-
defaultClip.current = defaultAnim.clone();
|
|
122
|
-
cameraRef.current.position.setY(size.y - 1.5 * 1.3); // Retro compatible with resources without eye bone
|
|
123
|
-
|
|
124
|
-
object.traverse(function (obj) {
|
|
125
|
-
if (obj.type === 'Bone' && (obj.name.toLowerCase() === 'l_eye' || obj.name.toLowerCase() === 'eye_l')) {
|
|
126
|
-
var leftEyeVector = new _three.Vector3().setFromMatrixPosition(obj.matrixWorld);
|
|
127
|
-
cameraRef.current.position.setY(leftEyeVector.y - 0.5);
|
|
128
|
-
}
|
|
129
|
-
});
|
|
68
|
+
cameraRef.current.position.setY(size.y - 1.5 * 1.3);
|
|
130
69
|
cameraRef.current.zoom = 1.85;
|
|
131
70
|
} else if (character.type === 'object') {
|
|
132
|
-
(0, _helpers.cameraFitAnyObject)(
|
|
71
|
+
(0, _helpers.cameraFitAnyObject)(model, cameraRef.current);
|
|
133
72
|
cameraRef.current.zoom = 1;
|
|
134
73
|
}
|
|
135
74
|
|
|
136
75
|
cameraRef.current.updateProjectionMatrix();
|
|
137
76
|
}
|
|
138
|
-
}, [character
|
|
77
|
+
}, [character]);
|
|
139
78
|
(0, _fiber.useFrame)(function (_ref2) {
|
|
140
79
|
var gl = _ref2.gl;
|
|
141
80
|
|
|
@@ -165,8 +104,9 @@ function Panel(_ref) {
|
|
|
165
104
|
}, 100);
|
|
166
105
|
return character.type === 'image' ? null : /*#__PURE__*/_react.default.createElement("scene", {
|
|
167
106
|
ref: sceneRef
|
|
168
|
-
}, (_character$
|
|
169
|
-
progressive: true
|
|
107
|
+
}, (_character$resource5 = character.resource) !== null && _character$resource5 !== void 0 && _character$resource5.url ? /*#__PURE__*/_react.default.createElement(_arcadeThreeCore.LodWrapper, {
|
|
108
|
+
progressive: true,
|
|
109
|
+
individualProgress: true
|
|
170
110
|
}, /*#__PURE__*/_react.default.createElement(_arcadeThreeCore.TriggerWrapper, {
|
|
171
111
|
name: "char_".concat(character.uid),
|
|
172
112
|
url: character.resource.url,
|
|
@@ -179,9 +119,7 @@ function Panel(_ref) {
|
|
|
179
119
|
fov: 35,
|
|
180
120
|
focus: 10,
|
|
181
121
|
ref: cameraRef,
|
|
182
|
-
position: defaultCamPos
|
|
183
|
-
makeDefault: true,
|
|
184
|
-
defaultCamera: true
|
|
122
|
+
position: defaultCamPos
|
|
185
123
|
}), /*#__PURE__*/_react.default.createElement(_LightSet.default, null));
|
|
186
124
|
}
|
|
187
125
|
|