@gamelearn/arcade-components 1.21.3 → 1.22.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.
Files changed (19) hide show
  1. package/dist/components/cards-selector-puzzle-component/components/CardsSelectorPuzzleComponent.js +6 -0
  2. package/dist/components/chained-image-click-puzzle-component/components/CurrentImagePuzzle.js +7 -0
  3. package/dist/components/conversational-pro-component/components/ConversationalProComponent.js +9 -2
  4. package/dist/components/cracker-puzzle-component/components/CrackerPuzzleComponent.js +3 -0
  5. package/dist/components/dialog-component/components/DialogComponent.js +10 -2
  6. package/dist/components/drag-item-puzzle-component/components/DragItemPuzzleComponent.js +6 -0
  7. package/dist/components/frame-click-puzzle-component/components/CurrentFramePuzzle.js +3 -0
  8. package/dist/components/frame-click-puzzle-component/components/FrameClickPuzzleComponent.js +3 -0
  9. package/dist/components/hacker-puzzle-component/components/HackerPuzzleComponent.js +3 -0
  10. package/dist/components/hanged-puzzle-component/components/HangedPuzzleComponent.js +6 -0
  11. package/dist/components/image-click-puzzle-component/components/ImageClickPuzzleComponent.js +6 -0
  12. package/dist/components/keyboard-puzzle-component/components/KeyboardPuzzleComponent.js +6 -0
  13. package/dist/components/login-puzzle-component/components/LoginPuzzleComponent.js +6 -0
  14. package/dist/components/terminal-puzzle-component/components/TerminalPuzzleComponent.js +3 -0
  15. package/dist/components/test-component/components/TestComponent.js +3 -0
  16. package/dist/components/text-click-puzzle-component/components/TextClickPuzzleComponent.js +7 -1
  17. package/dist/components/web-builder-puzzle-component/components/WebBuilderPuzzleComponent.js +6 -0
  18. package/dist/components/writer-puzzle-component/components/WriterPuzzleComponent.js +6 -0
  19. package/package.json +1 -1
@@ -116,6 +116,9 @@ var CardsSelectorPuzzleComponent = function CardsSelectorPuzzleComponent(_ref) {
116
116
  finish: true,
117
117
  payload: rewardsData
118
118
  });
119
+ emitEvent({
120
+ type: 'passPuzzle'
121
+ });
119
122
  }, [emitEvent]);
120
123
  var endPuzzle = (0, _react.useCallback)(function () {
121
124
  var _info$solution, _specificFeedbacks$co;
@@ -238,6 +241,9 @@ var CardsSelectorPuzzleComponent = function CardsSelectorPuzzleComponent(_ref) {
238
241
  type: 'hidePuzzleButtons',
239
242
  payload: true
240
243
  });
244
+ emitEvent({
245
+ type: 'failPuzzle'
246
+ });
241
247
  };
242
248
 
243
249
  (0, _react.useEffect)(function () {
@@ -92,6 +92,9 @@ var CurrentImageClickPuzzle = function CurrentImageClickPuzzle(_ref) {
92
92
  finish: true,
93
93
  payload: [].concat(_toConsumableArray(accRewards.current), _toConsumableArray(rewards))
94
94
  });
95
+ emitEvent({
96
+ type: 'passPuzzle'
97
+ });
95
98
  }, [playSound, emitEvent]);
96
99
  var currentImageProps = list[index];
97
100
  var info = currentImageProps.info,
@@ -135,6 +138,10 @@ var CurrentImageClickPuzzle = function CurrentImageClickPuzzle(_ref) {
135
138
  setSelected(selected - correctClicked.current);
136
139
  correctClicked.current = 0;
137
140
  }
141
+
142
+ emitEvent({
143
+ type: 'failPuzzle'
144
+ });
138
145
  }
139
146
  }, [index, list.length, currentImageProps.hasClickOrder, currentImageProps.hasClickOnce, currentImageProps.areas.length, handleFinish, specificFeedbacks, setSelected, selected, emitEvent]);
140
147
 
@@ -94,6 +94,12 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
94
94
  var voiceOver = currentLineData.voiceOver,
95
95
  decision = currentLineData.decision;
96
96
  var isBranched = !!edges;
97
+
98
+ var _useState9 = (0, _react.useState)(false),
99
+ _useState10 = _slicedToArray(_useState9, 2),
100
+ previousLineWasDecision = _useState10[0],
101
+ setPreviousLineWasDecision = _useState10[1];
102
+
97
103
  var isVoiceOver = voiceOver || currentLineData.type === 'conversationalNarration';
98
104
  var isDecision = decision || currentLineData.type === 'conversationalDecision';
99
105
  var isFlex = currentLineData.flex;
@@ -251,6 +257,7 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
251
257
  }
252
258
  }, [currentLineData.id, edges, finishConversation, lines]);
253
259
  var handleClickNext = (0, _react.useCallback)(function (choice, reset) {
260
+ setPreviousLineWasDecision(currentLineData.decision);
254
261
  setStarted(false);
255
262
  setAudioFailed(false);
256
263
 
@@ -272,7 +279,7 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
272
279
  }
273
280
 
274
281
  setStarted(true);
275
- }, [currentLine, finishConversation, handleBranchDirection, handleDecisionBranch, isBranched, lines.length]);
282
+ }, [currentLine, currentLineData, finishConversation, handleBranchDirection, handleDecisionBranch, isBranched, lines.length]);
276
283
 
277
284
  var handleClickBack = function handleClickBack() {
278
285
  setStarted(false);
@@ -300,7 +307,7 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
300
307
  };
301
308
 
302
309
  var autoplayCond = automatic && !isDecision;
303
- var disableBackButton = currentLine === 0 || currentLine > 0 && (lastLine === null || lastLine === void 0 ? void 0 : lastLine.decision);
310
+ var disableBackButton = currentLine === 0 || previousLineWasDecision || currentLine > 0 && (lastLine === null || lastLine === void 0 ? void 0 : lastLine.decision);
304
311
  var stopEkho = (0, _useEkho.default)({
305
312
  audioType: currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.audioType,
306
313
  voice: currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.voice,
@@ -160,6 +160,9 @@ var CrackerPuzzleComponent = function CrackerPuzzleComponent(_ref) {
160
160
  finish: true,
161
161
  payload: rewards
162
162
  });
163
+ emitEvent({
164
+ type: 'passPuzzle'
165
+ });
163
166
  };
164
167
 
165
168
  var generatePasswordPositions = function generatePasswordPositions() {
@@ -131,6 +131,7 @@ var DialogComponent = function DialogComponent(_ref) {
131
131
  var groupRef = (0, _react.useRef)();
132
132
  var animationTarget = (0, _react.useRef)(new _three.Object3D());
133
133
  var currentLine = lines[line];
134
+ var currentLineData = lines[line];
134
135
  var lastLine = lines[line - 1];
135
136
  var lastSet = (0, _react.useRef)(false);
136
137
  var isBranched = !!edges;
@@ -145,6 +146,12 @@ var DialogComponent = function DialogComponent(_ref) {
145
146
  payload: id
146
147
  });
147
148
  }, [emitEvent]);
149
+
150
+ var _useState9 = (0, _react.useState)(false),
151
+ _useState10 = _slicedToArray(_useState9, 2),
152
+ previousLineWasDecision = _useState10[0],
153
+ setPreviousLineWasDecision = _useState10[1];
154
+
148
155
  var isVoiceOver = voiceOver || (currentLine === null || currentLine === void 0 ? void 0 : currentLine.type) === 'conversationalNarration';
149
156
  var isDecision = decision || (currentLine === null || currentLine === void 0 ? void 0 : currentLine.type) === 'conversationalDecision';
150
157
  var getCurrentVisible = (0, _react.useCallback)(function (uid) {
@@ -303,6 +310,7 @@ var DialogComponent = function DialogComponent(_ref) {
303
310
  }
304
311
  }, [currentLine === null || currentLine === void 0 ? void 0 : currentLine.id, edges, finishConversation, lines]);
305
312
  var nextLine = (0, _react.useCallback)(function (choice, reset) {
313
+ setPreviousLineWasDecision(currentLineData.decision);
306
314
  setAudioFailed(false);
307
315
 
308
316
  if (isBranched) {
@@ -319,7 +327,7 @@ var DialogComponent = function DialogComponent(_ref) {
319
327
  } else {
320
328
  finishConversation();
321
329
  }
322
- }, [isBranched, line, lines.length, handleDecisionBranch, handleBranchDirection, finishConversation]);
330
+ }, [currentLineData.decision, isBranched, line, lines.length, handleDecisionBranch, handleBranchDirection, finishConversation]);
323
331
 
324
332
  var manualBackLine = function manualBackLine() {
325
333
  setAutomatic(false);
@@ -590,7 +598,7 @@ var DialogComponent = function DialogComponent(_ref) {
590
598
  height: '100vh',
591
599
  position: 'static'
592
600
  };
593
- var disableBackButton = line === 0 || line > 0 && (lastLine === null || lastLine === void 0 ? void 0 : lastLine.decision);
601
+ var disableBackButton = line === 0 || previousLineWasDecision || line > 0 && (lastLine === null || lastLine === void 0 ? void 0 : lastLine.decision);
594
602
 
595
603
  if (isDecision) {
596
604
  var decisionPayload = _objectSpread(_objectSpread({}, currentLine.payload), {}, {
@@ -174,6 +174,9 @@ var DragItemPuzzleComponent = function DragItemPuzzleComponent(_ref) {
174
174
  finish: true,
175
175
  payload: accRewards.current
176
176
  });
177
+ emitEvent({
178
+ type: 'passPuzzle'
179
+ });
177
180
 
178
181
  if (consume) {
179
182
  emitEvent({
@@ -214,6 +217,9 @@ var DragItemPuzzleComponent = function DragItemPuzzleComponent(_ref) {
214
217
  type: 'hidePuzzleButtons',
215
218
  payload: false
216
219
  });
220
+ emitEvent({
221
+ type: 'failPuzzle'
222
+ });
217
223
  accRewards.current = [].concat(_toConsumableArray(accRewards.current), _toConsumableArray(solution.wrong.rewards));
218
224
  }, [emitEvent, playSound, solution.wrong.rewards]);
219
225
  var handleDrop = (0, _react.useCallback)(function (e) {
@@ -117,6 +117,9 @@ var CurrentFramePuzzle = function CurrentFramePuzzle(_ref) {
117
117
  payload: rw,
118
118
  finish: false
119
119
  });
120
+ emitEvent({
121
+ type: 'failPuzzle'
122
+ });
120
123
 
121
124
  if (props.hasClickOrder) {
122
125
  setSelected(selected - correctClicked.current);
@@ -106,6 +106,9 @@ var FrameImageClickComponent = function FrameImageClickComponent(_ref) {
106
106
  finish: true,
107
107
  payload: [].concat(_toConsumableArray(accRewards.current), _toConsumableArray(rewards))
108
108
  });
109
+ emitEvent({
110
+ type: 'passPuzzle'
111
+ });
109
112
  }, [emitEvent]);
110
113
  var resetPuzzle = (0, _react.useCallback)(function () {
111
114
  setFirstTryForFrame(false);
@@ -138,6 +138,9 @@ var HackerPuzzleComponent = function HackerPuzzleComponent(_ref) {
138
138
  finish: true,
139
139
  payload: rewards
140
140
  });
141
+ emitEvent({
142
+ type: 'passPuzzle'
143
+ });
141
144
  };
142
145
 
143
146
  (0, _react.useEffect)(function () {
@@ -335,6 +335,9 @@ var HangedPuzzleComponent = function HangedPuzzleComponent(_ref4) {
335
335
  finish: true,
336
336
  payload: rewardsData
337
337
  });
338
+ emitEvent({
339
+ type: 'passPuzzle'
340
+ });
338
341
  };
339
342
 
340
343
  var handleFail = function handleFail() {
@@ -346,6 +349,9 @@ var HangedPuzzleComponent = function HangedPuzzleComponent(_ref4) {
346
349
  setRewards([].concat(_toConsumableArray(accRewards), _toConsumableArray(info.solution.wrong.rewards)));
347
350
  setResolveClass('');
348
351
  setDisable(false);
352
+ emitEvent({
353
+ type: 'failPuzzle'
354
+ });
349
355
  };
350
356
 
351
357
  var resolvePuzzle = function resolvePuzzle(newAnswer, newPool) {
@@ -22,12 +22,18 @@ var ImageClickPuzzleComponent = function ImageClickPuzzleComponent(props) {
22
22
  finish: true,
23
23
  payload: rw
24
24
  });
25
+ props.emitEvent({
26
+ type: 'passPuzzle'
27
+ });
25
28
  } else {
26
29
  props.emitEvent({
27
30
  type: 'addPoints',
28
31
  payload: rw,
29
32
  finish: false
30
33
  });
34
+ props.emitEvent({
35
+ type: 'failPuzzle'
36
+ });
31
37
  }
32
38
  };
33
39
 
@@ -140,6 +140,9 @@ var KeyboardPuzzleComponent = function KeyboardPuzzleComponent(_ref) {
140
140
  disableExit(false);
141
141
  setPassClass('success');
142
142
  playSound('score');
143
+ emitEvent({
144
+ type: 'passPuzzle'
145
+ });
143
146
  setFeedbackResult(true);
144
147
  setFeedbackIsShown(true);
145
148
 
@@ -156,6 +159,9 @@ var KeyboardPuzzleComponent = function KeyboardPuzzleComponent(_ref) {
156
159
  setFeedbackIsShown(true);
157
160
  setPassClass('failed');
158
161
  playSound('fail');
162
+ emitEvent({
163
+ type: 'failPuzzle'
164
+ });
159
165
  setFeedbackResult(false);
160
166
  setRewards([].concat(_toConsumableArray(accRewards), _toConsumableArray(info.solution.wrong.rewards)));
161
167
  emitEvent({
@@ -121,6 +121,9 @@ var LoginPuzzleComponent = function LoginPuzzleComponent(_ref) {
121
121
  finish: true,
122
122
  payload: rewardsData
123
123
  });
124
+ emitEvent({
125
+ type: 'passPuzzle'
126
+ });
124
127
  };
125
128
 
126
129
  var checkInput = function checkInput() {
@@ -150,6 +153,9 @@ var LoginPuzzleComponent = function LoginPuzzleComponent(_ref) {
150
153
  playSound('fail');
151
154
  setSuccessClass('failed');
152
155
  setErrorMessage(true);
156
+ emitEvent({
157
+ type: 'failPuzzle'
158
+ });
153
159
  }
154
160
  };
155
161
 
@@ -216,6 +216,9 @@ var TerminalPuzzleComponent = function TerminalPuzzleComponent(_ref) {
216
216
  finish: true,
217
217
  payload: rewards
218
218
  });
219
+ emitEvent({
220
+ type: 'passPuzzle'
221
+ });
219
222
  };
220
223
 
221
224
  var backgroundURL = (backgroundImage === null || backgroundImage === void 0 ? void 0 : backgroundImage.url) || DEFAULT_IMG;
@@ -226,6 +226,9 @@ var TestComponent = function TestComponent(_ref) {
226
226
  finish: false,
227
227
  onFinish: finishAddPoints
228
228
  });
229
+ emitEvent({
230
+ type: 'failTest'
231
+ });
229
232
  };
230
233
 
231
234
  var translate = function translate(id, values) {
@@ -139,6 +139,9 @@ var TextClickPuzzleComponent = function TextClickPuzzleComponent(_ref) {
139
139
  finish: true,
140
140
  payload: totalRewards
141
141
  });
142
+ emitEvent({
143
+ type: 'passPuzzle'
144
+ });
142
145
  } else {
143
146
  parsedText.current = null;
144
147
  setCurrentSlide(currentSlide + 1);
@@ -241,7 +244,10 @@ var TextClickPuzzleComponent = function TextClickPuzzleComponent(_ref) {
241
244
  type: 'hidePuzzleButtons',
242
245
  payload: true
243
246
  });
244
- playSound('fail'); // si tiene feedback general definido
247
+ playSound('fail');
248
+ emitEvent({
249
+ type: 'failPuzzle'
250
+ }); // si tiene feedback general definido
245
251
 
246
252
  if (list[currentSlide].info.solution.wrong.desc !== '') {
247
253
  accRewards.current = [].concat(_toConsumableArray(accRewards.current), _toConsumableArray(list[currentSlide].info.solution.wrong.rewards));
@@ -180,6 +180,9 @@ var WebBuilderPuzzleComponent = function WebBuilderPuzzleComponent(_ref) {
180
180
  finish: true,
181
181
  payload: failed ? wrongRewards : rewards
182
182
  });
183
+ emitEvent({
184
+ type: 'passPuzzle'
185
+ });
183
186
  }
184
187
  };
185
188
 
@@ -233,6 +236,9 @@ var WebBuilderPuzzleComponent = function WebBuilderPuzzleComponent(_ref) {
233
236
 
234
237
  showCurrentFeed('failed');
235
238
  setFailed(true);
239
+ emitEvent({
240
+ type: 'failPuzzle'
241
+ });
236
242
  } else if (exist && equal) {
237
243
  if (showPublish) {
238
244
  disableExit(false);
@@ -261,6 +261,9 @@ var WriterPuzzleComponent = function WriterPuzzleComponent(_ref) {
261
261
  payload: rewardsStack,
262
262
  onFinish: type !== 'view' ? handleLectures : null
263
263
  });
264
+ emitEvent({
265
+ type: 'passPuzzle'
266
+ });
264
267
  };
265
268
 
266
269
  var retryPuzzle = function retryPuzzle() {
@@ -286,6 +289,9 @@ var WriterPuzzleComponent = function WriterPuzzleComponent(_ref) {
286
289
  finish: false,
287
290
  payload: rewardsStack
288
291
  });
292
+ emitEvent({
293
+ type: 'failPuzzle'
294
+ });
289
295
  };
290
296
 
291
297
  var handleFinish = function handleFinish() {
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.21.3",
5
+ "version": "1.22.1",
6
6
  "main": "dist/index.js",
7
7
  "files": [
8
8
  "dist",