@gamelearn/arcade-components 1.22.15 → 1.23.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.
@@ -120,7 +120,7 @@ var ComicComponent = function ComicComponent(_ref) {
120
120
  goToPreviousSlide();
121
121
  };
122
122
 
123
- var stopEkho = (0, _useEkho.default)({
123
+ (0, _useEkho.default)({
124
124
  audioType: slides === null || slides === void 0 ? void 0 : (_slides$slideCount = slides[slideCount]) === null || _slides$slideCount === void 0 ? void 0 : _slides$slideCount.audioType,
125
125
  voice: slides === null || slides === void 0 ? void 0 : (_slides$slideCount2 = slides[slideCount]) === null || _slides$slideCount2 === void 0 ? void 0 : _slides$slideCount2.voice,
126
126
  text: slides === null || slides === void 0 ? void 0 : (_slides$slideCount3 = slides[slideCount]) === null || _slides$slideCount3 === void 0 ? void 0 : (_slides$slideCount3$v = _slides$slideCount3.vignettes[0].textData) === null || _slides$slideCount3$v === void 0 ? void 0 : _slides$slideCount3$v.text,
@@ -137,9 +137,6 @@ var ComicComponent = function ComicComponent(_ref) {
137
137
  }
138
138
  }
139
139
  });
140
- (0, _react.useEffect)(function () {
141
- stopEkho();
142
- }, [slideCount, stopEkho]);
143
140
  (0, _react.useEffect)(function () {
144
141
  if (automatic && ((slide === null || slide === void 0 ? void 0 : slide.audioType) === 'none' || audioFailed)) {
145
142
  var _slide$vignettes$, _slide$vignettes$$tex;
@@ -86,8 +86,9 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
86
86
  currentLine = _useState10[0],
87
87
  setCurrentLine = _useState10[1];
88
88
 
89
- var _soundActions = _slicedToArray(soundActions, 1),
90
- playSound = _soundActions[0];
89
+ var _soundActions = _slicedToArray(soundActions, 2),
90
+ playSound = _soundActions[0],
91
+ stopSound = _soundActions[1];
91
92
 
92
93
  var _useTimeout = (0, _useTimeout2.default)(),
93
94
  start = _useTimeout.start,
@@ -313,7 +314,7 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
313
314
 
314
315
  var autoplayCond = automatic && !isDecision;
315
316
  var disableBackButton = currentLine === 0 || previousLineWasDecision || currentLine > 0 && (lastLine === null || lastLine === void 0 ? void 0 : lastLine.decision);
316
- var stopEkho = (0, _useEkho.default)({
317
+ (0, _useEkho.default)({
317
318
  audioType: currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.audioType,
318
319
  voice: currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.voice,
319
320
  started: started,
@@ -329,10 +330,7 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
329
330
  handleClickNext();
330
331
  }
331
332
  }
332
- });
333
- (0, _react.useEffect)(function () {
334
- stopEkho();
335
- }, [currentLine, stopEkho]); // Autoplay logic
333
+ }); // Autoplay logic
336
334
 
337
335
  (0, _react.useEffect)(function () {
338
336
  if (autoplayCond && ((currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.audioType) === 'none' || audioFailed)) {
@@ -466,48 +466,52 @@ var DialogComponent = function DialogComponent(_ref) {
466
466
  (0, _helpers.executeCrossFade)(startAction, action, crossFadeDuration);
467
467
  }
468
468
 
469
- if (talkingCharacter.uid === element.uid) {
470
- var showArrowTop = talkingCharacter.text.length > maxCharacterToSwitch;
471
- var head = element.getObjectByName('Head_M');
472
- var target = new _three.Object3D();
473
- head.getWorldPosition(target.position);
474
- target.applyQuaternion(camera.quaternion);
475
- var distance = camera.position.distanceTo(target.position);
476
- var staticDisplay = distance > 70 && !zoomInActor && !showArrowTop;
477
- target.translateY(staticDisplay || showArrowTop ? 0 : 3); // Detectar posicion de personaje a izq o derecha de pantalla
478
-
479
- var vector = new _three.Vector3();
480
- vector.setFromMatrixPosition(head.matrixWorld);
481
- var p = vector.project(defaultCamera);
482
- var isLeft = p.x < 0;
483
- messagePosition.current = {
484
- pos: target.position.toArray(),
485
- child: head,
486
- parent: element,
487
- isLeft: isLeft
488
- };
489
-
490
- if (zoomInActor) {
491
- setAnimationRunning(true);
492
- } // Ugly timeout to wait for zoom in ( maybe use tween (?))
493
-
494
-
495
- setTimeout(function () {
496
- var _talkingCharacter$cha;
497
-
498
- distance = camera.position.distanceTo(target.position);
499
- setCurrentMessage({
500
- text: talkingCharacter.text,
501
- name: talkingCharacter.alias || ((_talkingCharacter$cha = talkingCharacter.character) === null || _talkingCharacter$cha === void 0 ? void 0 : _talkingCharacter$cha.name),
502
- left: true,
503
- top: showArrowTop || distance > 70,
504
- inScene: true,
505
- thinkful: talkingCharacter.emotion === 'thinkful',
506
- avatar: '',
507
- show: true
508
- });
509
- }, zoomInActor ? 1000 : 0);
510
- }
469
+ setTimeout(function () {
470
+ if (talkingCharacter.uid === element.uid) {
471
+ var showArrowTop = talkingCharacter.text.length > maxCharacterToSwitch;
472
+ var head = element.getObjectByName('Head_M');
473
+ var target = new _three.Object3D();
474
+ head.updateMatrix();
475
+ head.updateMatrixWorld();
476
+ head.getWorldPosition(target.position);
477
+ target.applyQuaternion(camera.quaternion);
478
+ var distance = camera.position.distanceTo(target.position);
479
+ var staticDisplay = distance > 70 && !zoomInActor && !showArrowTop;
480
+ target.translateY(staticDisplay || showArrowTop ? 0 : 3); // Detectar posicion de personaje a izq o derecha de pantalla
481
+
482
+ var vector = new _three.Vector3();
483
+ vector.setFromMatrixPosition(head.matrixWorld);
484
+ var p = vector.project(defaultCamera);
485
+ var isLeft = p.x < 0;
486
+ messagePosition.current = {
487
+ pos: target.position.toArray(),
488
+ child: head,
489
+ parent: element,
490
+ isLeft: isLeft
491
+ };
492
+
493
+ if (zoomInActor) {
494
+ setAnimationRunning(true);
495
+ } // Ugly timeout to wait for zoom in ( maybe use tween (?))
496
+
497
+
498
+ setTimeout(function () {
499
+ var _talkingCharacter$cha;
500
+
501
+ distance = camera.position.distanceTo(target.position);
502
+ setCurrentMessage({
503
+ text: talkingCharacter.text,
504
+ name: talkingCharacter.alias || ((_talkingCharacter$cha = talkingCharacter.character) === null || _talkingCharacter$cha === void 0 ? void 0 : _talkingCharacter$cha.name),
505
+ left: true,
506
+ top: showArrowTop || distance > 70,
507
+ inScene: true,
508
+ thinkful: talkingCharacter.emotion === 'thinkful',
509
+ avatar: '',
510
+ show: true
511
+ });
512
+ }, zoomInActor ? 1200 : 0);
513
+ }
514
+ }, crossFadeDuration * 100);
511
515
  });
512
516
  } else {
513
517
  var _talkingCharacter$cha2;
@@ -555,6 +559,9 @@ var DialogComponent = function DialogComponent(_ref) {
555
559
  });
556
560
  (0, _react.useEffect)(function () {
557
561
  stopEkho();
562
+ return function () {
563
+ stopEkho();
564
+ };
558
565
  }, [line, stopEkho]); // Autoplay logic
559
566
 
560
567
  (0, _react.useEffect)(function () {
@@ -630,9 +637,9 @@ var DialogComponent = function DialogComponent(_ref) {
630
637
  }
631
638
 
632
639
  var mult = messagePosition.current.isLeft ? -1 : 1;
633
- var headSpace = 2.25 * mult; // move bubble
640
+ var headSpace = 2 * mult; // move bubble
634
641
 
635
- messagePosition.current.pos[0] -= 1.25;
642
+ messagePosition.current.pos[0] -= headSpace;
636
643
  animationTarget.current.translateX(-10 * mult - headSpace);
637
644
  animationTarget.current.translateY(-5);
638
645
  animationTarget.current.translateZ(30);
@@ -31,7 +31,10 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
31
31
 
32
32
  var BufferBar = function BufferBar(_ref) {
33
33
  var time = _ref.time,
34
- setTimePoint = _ref.setTimePoint;
34
+ setTimePoint = _ref.setTimePoint,
35
+ mandatory = _ref.mandatory,
36
+ mandatoryHasBeenViewed = _ref.mandatoryHasBeenViewed,
37
+ viewed = _ref.viewed;
35
38
  var barPercentage = Math.trunc(time.current * 1000 / time.duration) / 10;
36
39
 
37
40
  var barRef = /*#__PURE__*/_react.default.createRef();
@@ -76,10 +79,12 @@ var BufferBar = function BufferBar(_ref) {
76
79
  };
77
80
 
78
81
  var _onMouseDown = function onMouseDown(event, buffer) {
79
- event.preventDefault();
80
- setTimePoint(event.clientX, buffer.offsetWidth, buffer.offsetLeft);
81
- windowMove(buffer);
82
- move(true);
82
+ if (!mandatory || mandatory && mandatoryHasBeenViewed || viewed) {
83
+ event.preventDefault();
84
+ setTimePoint(event.clientX, buffer.offsetWidth, buffer.offsetLeft);
85
+ windowMove(buffer);
86
+ move(true);
87
+ }
83
88
  };
84
89
 
85
90
  return /*#__PURE__*/_react.default.createElement("div", {
@@ -13,8 +13,9 @@ var skipButton = function skipButton(_ref) {
13
13
  var viewed = _ref.viewed,
14
14
  mandatory = _ref.mandatory,
15
15
  finished = _ref.finished,
16
- skip = _ref.skip;
17
- return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, mandatory && viewed || !mandatory || finished ? /*#__PURE__*/_react.default.createElement("div", {
16
+ skip = _ref.skip,
17
+ mandatoryHasBeenViewed = _ref.mandatoryHasBeenViewed;
18
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, mandatory && viewed || !mandatory || finished || mandatoryHasBeenViewed ? /*#__PURE__*/_react.default.createElement("div", {
18
19
  className: "position--absolute right top z-index1"
19
20
  }, /*#__PURE__*/_react.default.createElement("div", {
20
21
  className: "gat--btn__round",
@@ -40,7 +40,8 @@ var VideoControllers = function VideoControllers(_ref) {
40
40
  mute = _ref.mute,
41
41
  setVolume = _ref.setVolume,
42
42
  setTimePoint = _ref.setTimePoint,
43
- audioAnimation = _ref.audioAnimation;
43
+ audioAnimation = _ref.audioAnimation,
44
+ mandatoryHasBeenViewed = _ref.mandatoryHasBeenViewed;
44
45
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, audioAnimation ? null : /*#__PURE__*/_react.default.createElement(_PlayInitButton.default, {
45
46
  play: pause,
46
47
  paused: paused,
@@ -53,12 +54,17 @@ var VideoControllers = function VideoControllers(_ref) {
53
54
  finished: finished,
54
55
  viewed: viewed,
55
56
  skip: skip,
56
- rewind: rewind
57
+ rewind: rewind,
58
+ mandatoryHasBeenViewed: mandatoryHasBeenViewed
57
59
  }), /*#__PURE__*/_react.default.createElement("div", {
58
60
  className: "video--controls"
59
61
  }, /*#__PURE__*/_react.default.createElement(_BufferBar.default, {
62
+ mandatory: mandatory,
63
+ mandatoryHasBeenViewed: mandatoryHasBeenViewed,
60
64
  time: time,
61
- setTimePoint: setTimePoint
65
+ setTimePoint: setTimePoint,
66
+ finished: finished,
67
+ viewed: viewed
62
68
  }), /*#__PURE__*/_react.default.createElement("div", {
63
69
  className: "video--controls__actions"
64
70
  }, /*#__PURE__*/_react.default.createElement(_Timer.default, {
@@ -44,48 +44,53 @@ var VideoVisor = function VideoVisor(_ref) {
44
44
  soundActions = _ref.soundActions,
45
45
  endVideo = _ref.endVideo;
46
46
 
47
+ var _useState = (0, _react.useState)(false),
48
+ _useState2 = _slicedToArray(_useState, 2),
49
+ mandatoryHasBeenViewed = _useState2[0],
50
+ setmandatoryHasBeenViewed = _useState2[1];
51
+
47
52
  var _soundActions = _slicedToArray(soundActions, 1),
48
53
  playSound = _soundActions[0];
49
54
 
50
- var _useState = (0, _react.useState)(0),
51
- _useState2 = _slicedToArray(_useState, 2),
52
- duration = _useState2[0],
53
- setDuration = _useState2[1];
54
-
55
55
  var _useState3 = (0, _react.useState)(0),
56
56
  _useState4 = _slicedToArray(_useState3, 2),
57
- loadedPercentage = _useState4[0],
58
- setLoadedPercentage = _useState4[1];
57
+ duration = _useState4[0],
58
+ setDuration = _useState4[1];
59
59
 
60
- var _useState5 = (0, _react.useState)(false),
60
+ var _useState5 = (0, _react.useState)(0),
61
61
  _useState6 = _slicedToArray(_useState5, 2),
62
- loading = _useState6[0],
63
- setLoading = _useState6[1];
62
+ loadedPercentage = _useState6[0],
63
+ setLoadedPercentage = _useState6[1];
64
64
 
65
- var _useState7 = (0, _react.useState)(true),
65
+ var _useState7 = (0, _react.useState)(false),
66
66
  _useState8 = _slicedToArray(_useState7, 2),
67
- paused = _useState8[0],
68
- setPaused = _useState8[1];
67
+ loading = _useState8[0],
68
+ setLoading = _useState8[1];
69
69
 
70
- var _useState9 = (0, _react.useState)(false),
70
+ var _useState9 = (0, _react.useState)(true),
71
71
  _useState10 = _slicedToArray(_useState9, 2),
72
- isFinish = _useState10[0],
73
- setIsFinish = _useState10[1];
72
+ paused = _useState10[0],
73
+ setPaused = _useState10[1];
74
74
 
75
- var _useState11 = (0, _react.useState)(),
75
+ var _useState11 = (0, _react.useState)(false),
76
76
  _useState12 = _slicedToArray(_useState11, 2),
77
- videoPlayer = _useState12[0],
78
- setVideo = _useState12[1];
77
+ isFinish = _useState12[0],
78
+ setIsFinish = _useState12[1];
79
79
 
80
- var _useState13 = (0, _react.useState)(0),
80
+ var _useState13 = (0, _react.useState)(),
81
81
  _useState14 = _slicedToArray(_useState13, 2),
82
- volume = _useState14[0],
83
- setVolume = _useState14[1];
82
+ videoPlayer = _useState14[0],
83
+ setVideo = _useState14[1];
84
84
 
85
- var _useState15 = (0, _react.useState)(false),
85
+ var _useState15 = (0, _react.useState)(0),
86
86
  _useState16 = _slicedToArray(_useState15, 2),
87
- hiddenControls = _useState16[0],
88
- hideControls = _useState16[1];
87
+ volume = _useState16[0],
88
+ setVolume = _useState16[1];
89
+
90
+ var _useState17 = (0, _react.useState)(false),
91
+ _useState18 = _slicedToArray(_useState17, 2),
92
+ hiddenControls = _useState18[0],
93
+ hideControls = _useState18[1];
89
94
 
90
95
  var isHls = url && url.match(/\.m3u8(\?.+=.+)*$/i) && _hls.default.isSupported();
91
96
 
@@ -103,6 +108,10 @@ var VideoVisor = function VideoVisor(_ref) {
103
108
  };
104
109
 
105
110
  var onEnded = function onEnded() {
111
+ if (required) {
112
+ setmandatoryHasBeenViewed(true);
113
+ }
114
+
106
115
  setLoading(false);
107
116
  videoPlayer.pause();
108
117
  setPaused(true);
@@ -230,9 +239,10 @@ var VideoVisor = function VideoVisor(_ref) {
230
239
  backgroundPosition: 'center center'
231
240
  };
232
241
  return /*#__PURE__*/_react.default.createElement("div", {
233
- className: "video",
242
+ className: "video ".concat(required && !mandatoryHasBeenViewed && !viewed ? 'forward-disabled' : ''),
234
243
  style: isAudio ? configForAudio : null
235
244
  }, !isEmbeddedVideo ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, !hiddenControls && /*#__PURE__*/_react.default.createElement(_VideoControllers.default, {
245
+ mandatoryHasBeenViewed: mandatoryHasBeenViewed,
236
246
  audioAnimation: !!isAudio,
237
247
  skip: endVideo,
238
248
  mandatory: required,
@@ -33,6 +33,10 @@ var mockProps = [{
33
33
  imgId: 'https://min.int.gamelearn.io/cooked.gl-lms-storage/clients/58dccfba26561500117caf53/image/60224b7a901f3e0012350158/vista-vertical-torre-eiffel-paris-francia_1258-3169.jpg',
34
34
  soundActions: _mocker.soundActions,
35
35
  url: 'https://min.int.gamelearn.io/cooked.gl-lms-storage/clients/58dccfba26561500117caf53/documents/Cat-sound.mp3'
36
+ }, {
37
+ url: "".concat(path, "/triskelion-statics/videos/ada_hack.mp4"),
38
+ soundActions: _mocker.soundActions,
39
+ required: true
36
40
  }];
37
41
  exports.mockProps = mockProps;
38
42
  var _default = mockProps;
@@ -7,12 +7,6 @@ exports.default = void 0;
7
7
 
8
8
  var _react = require("react");
9
9
 
10
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
11
-
12
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
13
-
14
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
15
-
16
10
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
17
11
 
18
12
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
@@ -163,9 +157,10 @@ var useEkho = function useEkho(_ref) {
163
157
  }(), [emitEvent, onError, setCurrentPlaying]);
164
158
  var stopCurrentAudio = (0, _react.useCallback)(function () {
165
159
  if (currentPlaying.current.url) {
166
- currentPlaying.current = _objectSpread(_objectSpread({}, currentPlaying.current), {}, {
167
- url: ''
168
- });
160
+ currentPlaying.current = {
161
+ url: '',
162
+ cc: 'tts'
163
+ };
169
164
  stop(currentPlaying.current.cc);
170
165
  }
171
166
  }, [stop]);
@@ -176,6 +171,8 @@ var useEkho = function useEkho(_ref) {
176
171
  }, [noAudio, stopCurrentAudio]);
177
172
  (0, _react.useEffect)(function () {
178
173
  if (isMounted && started) {
174
+ stopCurrentAudio();
175
+
179
176
  if (audioType === 'voice' && voice !== null && voice !== void 0 && voice.id) {
180
177
  var voiceId = getVoice(voice);
181
178
  playSpeech({
@@ -188,7 +185,7 @@ var useEkho = function useEkho(_ref) {
188
185
  onError();
189
186
  }
190
187
  }
191
- }, [getVoice, playSpeech, isMounted, voice, text, audioType, audio === null || audio === void 0 ? void 0 : audio.url, audio, setCurrentPlaying, onError, started]);
188
+ }, [getVoice, playSpeech, isMounted, voice, text, audioType, audio === null || audio === void 0 ? void 0 : audio.url, audio, setCurrentPlaying, onError, started, stopCurrentAudio]);
192
189
  return stopCurrentAudio;
193
190
  };
194
191
 
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@gamelearn/arcade-components",
3
3
  "author": "Gamelearn",
4
4
  "license": "unlicense",
5
- "version": "1.22.15",
5
+ "version": "1.23.0",
6
6
  "main": "dist/index.js",
7
7
  "files": [
8
8
  "dist",
@@ -13,7 +13,7 @@
13
13
  "url": "https://github.com/gamelearn/arcade-components"
14
14
  },
15
15
  "dependencies": {
16
- "@gamelearn/arcade-styles": "0.11.8",
16
+ "@gamelearn/arcade-styles": "0.11.10",
17
17
  "@gamelearn/arcade-three-core": "1.1.15",
18
18
  "@react-three/drei": "8.8.1",
19
19
  "@react-three/fiber": "7.0.25",