@gamelearn/arcade-components 2.27.0 → 2.28.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.
- package/dist/components/animation-component/components/AnimationComponent.js +10 -28
- package/dist/components/animation-component/index.js +0 -3
- package/dist/components/animation-component/mocks/mockForStory.js +0 -3
- package/dist/components/auto-evaluation-component/components/AutoEvaluation.js +30 -71
- package/dist/components/auto-evaluation-component/components/EndScreen.js +1 -9
- package/dist/components/auto-evaluation-component/components/StartScreen.js +2 -6
- package/dist/components/auto-evaluation-component/index.js +0 -3
- package/dist/components/auto-evaluation-component/mocks/mockForStory.js +0 -2
- package/dist/components/cards-selector-puzzle-component/components/Board/index.js +23 -55
- package/dist/components/cards-selector-puzzle-component/components/Card/index.js +4 -23
- package/dist/components/cards-selector-puzzle-component/components/CardsSelectorPuzzleComponent.js +41 -92
- package/dist/components/cards-selector-puzzle-component/index.js +0 -3
- package/dist/components/cards-selector-puzzle-component/mocks/mockForStory.js +4 -10
- package/dist/components/cartel-component/components/CartelComponent.js +12 -39
- package/dist/components/cartel-component/index.js +0 -3
- package/dist/components/chained-image-click-puzzle-component/components/ChainedImageClickPuzzleComponent.js +20 -38
- package/dist/components/chained-image-click-puzzle-component/components/CurrentImagePuzzle.js +25 -64
- package/dist/components/chained-image-click-puzzle-component/index.js +0 -3
- package/dist/components/chained-image-click-puzzle-component/mocks/mockForStory.js +1 -2
- package/dist/components/comic-component/components/ComicComponent.js +27 -62
- package/dist/components/comic-component/components/Slide.js +2 -7
- package/dist/components/comic-component/components/Vignette.js +7 -23
- package/dist/components/comic-component/index.js +0 -3
- package/dist/components/comic-component/mocks/mockForStory.js +1 -2
- package/dist/components/conversational-component/components/ConversationalComponent.js +15 -39
- package/dist/components/conversational-component/index.js +0 -3
- package/dist/components/conversational-pro-component/components/ConversationalProComponent.js +54 -137
- package/dist/components/conversational-pro-component/components/Message.js +1 -9
- package/dist/components/conversational-pro-component/components/Slot.js +3 -20
- package/dist/components/conversational-pro-component/components/SlotList.js +16 -40
- package/dist/components/conversational-pro-component/components/scene/Panel.js +12 -54
- package/dist/components/conversational-pro-component/components/scene/Panels.js +10 -17
- package/dist/components/conversational-pro-component/components/scene/index.js +11 -30
- package/dist/components/conversational-pro-component/index.js +0 -3
- package/dist/components/conversational-pro-component/mocks/mockForStory.js +1 -2
- package/dist/components/cracker-puzzle-component/components/CrackerPuzzleComponent.js +35 -89
- package/dist/components/cracker-puzzle-component/components/DrawGrid/index.js +3 -7
- package/dist/components/cracker-puzzle-component/components/DrawItem/index.js +4 -9
- package/dist/components/cracker-puzzle-component/components/DrawRow/index.js +4 -9
- package/dist/components/cracker-puzzle-component/components/helpers.js +15 -55
- package/dist/components/cracker-puzzle-component/index.js +0 -3
- package/dist/components/cracker-puzzle-component/mocks/mockForStory.js +0 -2
- package/dist/components/decision-component/components/DecisionBody.js +19 -44
- package/dist/components/decision-component/components/DecisionComponent.js +22 -70
- package/dist/components/decision-component/components/Feedback.js +2 -11
- package/dist/components/decision-component/components/Options.js +12 -31
- package/dist/components/decision-component/index.js +0 -3
- package/dist/components/decision-component/mocks/mockForStory.js +0 -2
- package/dist/components/dialog-component/components/BubbleWrapper.js +1 -7
- package/dist/components/dialog-component/components/DialogComponent.js +118 -338
- package/dist/components/dialog-component/components/DialogDecision.js +3 -13
- package/dist/components/dialog-component/components/SpeechBubbleComponent.js +6 -24
- package/dist/components/dialog-component/index.js +0 -3
- package/dist/components/dialog-component/mocks/mockForStory.js +1 -5
- package/dist/components/drag-item-puzzle-component/components/DragItemPuzzleComponent.js +34 -90
- package/dist/components/drag-item-puzzle-component/components/Messages.js +0 -4
- package/dist/components/drag-item-puzzle-component/index.js +0 -3
- package/dist/components/drag-item-puzzle-component/mocks/mockForStory.js +1 -2
- package/dist/components/feedback-component/components/FeedbackComponent.js +16 -41
- package/dist/components/feedback-component/index.js +0 -3
- package/dist/components/feedback-component/mocks/mockForStory.js +1 -2
- package/dist/components/frame-click-puzzle-component/components/Counter/index.js +3 -8
- package/dist/components/frame-click-puzzle-component/components/CurrentFramePuzzle.js +36 -68
- package/dist/components/frame-click-puzzle-component/components/FrameClickPuzzleComponent.js +33 -68
- package/dist/components/frame-click-puzzle-component/components/Tooltip/index.js +0 -6
- package/dist/components/frame-click-puzzle-component/index.js +0 -3
- package/dist/components/frame-click-puzzle-component/mocks/mockForStory.js +1 -2
- package/dist/components/hacker-puzzle-component/components/HackerPuzzleComponent.js +29 -69
- package/dist/components/hacker-puzzle-component/index.js +0 -3
- package/dist/components/hacker-puzzle-component/mocks/mockForStory.js +0 -2
- package/dist/components/hanged-puzzle-component/components/HangedPuzzleComponent.js +48 -123
- package/dist/components/hanged-puzzle-component/index.js +0 -3
- package/dist/components/hanged-puzzle-component/mocks/mockForStory.js +0 -3
- package/dist/components/hanged-puzzle-component/utils.js +0 -20
- package/dist/components/image-click-puzzle-component/components/ImageClickPuzzleComponent.js +1 -8
- package/dist/components/image-click-puzzle-component/index.js +0 -3
- package/dist/components/image-click-puzzle-component/mocks/mockForStory.js +0 -2
- package/dist/components/image-click-wrapper-component/components/CountDown/index.js +0 -4
- package/dist/components/image-click-wrapper-component/components/ImageClickWrapperComponent.js +67 -134
- package/dist/components/image-click-wrapper-component/components/TimerDialog/index.js +2 -6
- package/dist/components/image-click-wrapper-component/index.js +0 -3
- package/dist/components/image-click-wrapper-component/mocks/mockForStory.js +0 -2
- package/dist/components/image-component/components/ImageComponent.js +14 -33
- package/dist/components/image-component/index.js +0 -3
- package/dist/components/image-component/mocks/mockForStory.js +0 -2
- package/dist/components/index.js +0 -39
- package/dist/components/inventory-item/components/InventoryItem.js +9 -35
- package/dist/components/inventory-item/index.js +0 -3
- package/dist/components/inventory-item/mocks/mockForStory.js +0 -3
- package/dist/components/keyboard-puzzle-component/components/KeyboardPuzzleComponent.js +33 -75
- package/dist/components/keyboard-puzzle-component/index.js +0 -3
- package/dist/components/keyboard-puzzle-component/mocks/mockForStory.js +0 -2
- package/dist/components/konva-components/Area/index.js +15 -44
- package/dist/components/konva-components/KonvaMapper.js +19 -42
- package/dist/components/lectures-component/components/LectureButtons.js +4 -8
- package/dist/components/lectures-component/components/LecturesComponent.js +29 -55
- package/dist/components/lectures-component/index.js +0 -3
- package/dist/components/lectures-component/mocks/mockForStory.js +6 -9
- package/dist/components/login-puzzle-component/components/LoginPuzzleComponent.js +38 -80
- package/dist/components/login-puzzle-component/index.js +0 -3
- package/dist/components/login-puzzle-component/mocks/mockForStory.js +0 -2
- package/dist/components/notice-component/components/NoticeComponent.js +8 -21
- package/dist/components/notice-component/index.js +0 -3
- package/dist/components/notice-component/mocks/mockForStory.js +0 -2
- package/dist/components/pattern-component/components/PatternComponent.js +8 -24
- package/dist/components/pattern-component/index.js +0 -3
- package/dist/components/pattern-component/mocks/mockForStory.js +0 -2
- package/dist/components/pdf-component/components/PdfComponent.js +23 -55
- package/dist/components/pdf-component/components/PdfVisor.js +22 -58
- package/dist/components/pdf-component/index.js +0 -3
- package/dist/components/pdf-component/mocks/mockForProps.js +1 -2
- package/dist/components/referral-component/components/EmailPill.js +2 -6
- package/dist/components/referral-component/components/ReferralComponent.js +30 -59
- package/dist/components/referral-component/components/StepOne.js +14 -48
- package/dist/components/referral-component/components/StepTwo.js +8 -23
- package/dist/components/referral-component/index.js +0 -3
- package/dist/components/referral-component/mocks/mockForStory.js +0 -2
- package/dist/components/survey-component/components/ApplicableBox.js +8 -15
- package/dist/components/survey-component/components/OpinionBox.js +8 -15
- package/dist/components/survey-component/components/SurveyComponent.js +13 -40
- package/dist/components/survey-component/components/TextBox.js +7 -13
- package/dist/components/survey-component/index.js +0 -3
- package/dist/components/survey-component/mocks/mockForStory.js +0 -2
- package/dist/components/terminal-puzzle-component/components/FilesGroup/Item.js +1 -6
- package/dist/components/terminal-puzzle-component/components/FilesGroup/index.js +4 -10
- package/dist/components/terminal-puzzle-component/components/Image/index.js +2 -6
- package/dist/components/terminal-puzzle-component/components/TerminalPuzzleComponent.js +26 -65
- package/dist/components/terminal-puzzle-component/components/Visor/index.js +15 -35
- package/dist/components/terminal-puzzle-component/components/utils/index.js +0 -3
- package/dist/components/terminal-puzzle-component/index.js +0 -3
- package/dist/components/terminal-puzzle-component/mocks/mockForStory.js +1 -2
- package/dist/components/test-component/components/Container.js +26 -60
- package/dist/components/test-component/components/Feedbacks.js +3 -13
- package/dist/components/test-component/components/Questions.js +11 -45
- package/dist/components/test-component/components/Results.js +28 -52
- package/dist/components/test-component/components/TestComponent.js +59 -110
- package/dist/components/test-component/index.js +0 -3
- package/dist/components/test-component/mocks/mockForStory.js +4 -8
- package/dist/components/text-click-puzzle-component/components/TextClickPuzzleComponent.js +58 -95
- package/dist/components/text-click-puzzle-component/index.js +0 -3
- package/dist/components/text-click-puzzle-component/mocks/mockForStory.js +1 -2
- package/dist/components/text-click-puzzle-component/utils/index.js +6 -31
- package/dist/components/url-component/components/UrlComponent.js +16 -34
- package/dist/components/url-component/index.js +0 -3
- package/dist/components/url-component/mocks/mockForProps.js +0 -2
- package/dist/components/video-component/components/VideoComponent.js +11 -25
- package/dist/components/video-component/index.js +0 -3
- package/dist/components/video-component/mocks/mockForStory.js +0 -2
- package/dist/components/video-visor/components/VideoControllers/BufferBar.js +10 -37
- package/dist/components/video-visor/components/VideoControllers/ControlButtons.js +2 -6
- package/dist/components/video-visor/components/VideoControllers/FinishedVideoButtons.js +1 -5
- package/dist/components/video-visor/components/VideoControllers/PlayInitButton.js +2 -8
- package/dist/components/video-visor/components/VideoControllers/SkipButton.js +5 -9
- package/dist/components/video-visor/components/VideoControllers/Timer.js +0 -5
- package/dist/components/video-visor/components/VideoControllers/VolumeBar.js +4 -20
- package/dist/components/video-visor/components/VideoControllers/index.js +17 -29
- package/dist/components/video-visor/components/VideoVisor.js +38 -92
- package/dist/components/video-visor/index.js +0 -3
- package/dist/components/video-visor/mocks/mockForStory.js +1 -2
- package/dist/components/web-builder-puzzle-component/Popups/PopupColorComponent/index.js +11 -28
- package/dist/components/web-builder-puzzle-component/Popups/PopupImageComponent/index.js +10 -27
- package/dist/components/web-builder-puzzle-component/Popups/PopupTextComponent/index.js +13 -36
- package/dist/components/web-builder-puzzle-component/Popups/index.js +0 -4
- package/dist/components/web-builder-puzzle-component/Templates/Facebook.js +0 -2
- package/dist/components/web-builder-puzzle-component/components/EditButton/index.js +1 -5
- package/dist/components/web-builder-puzzle-component/components/Feedback/index.js +3 -7
- package/dist/components/web-builder-puzzle-component/components/PublishButton/index.js +1 -5
- package/dist/components/web-builder-puzzle-component/components/WebBuilderBody/BankBody.js +5 -12
- package/dist/components/web-builder-puzzle-component/components/WebBuilderBody/FacebookBody.js +5 -11
- package/dist/components/web-builder-puzzle-component/components/WebBuilderBody/index.js +0 -7
- package/dist/components/web-builder-puzzle-component/components/WebBuilderFront/index.js +5 -14
- package/dist/components/web-builder-puzzle-component/components/WebBuilderHeader/BankHeader.js +5 -13
- package/dist/components/web-builder-puzzle-component/components/WebBuilderHeader/FacebookHeader.js +3 -8
- package/dist/components/web-builder-puzzle-component/components/WebBuilderHeader/index.js +3 -10
- package/dist/components/web-builder-puzzle-component/components/WebBuilderPuzzleComponent.js +47 -112
- package/dist/components/web-builder-puzzle-component/components/WebBuilderTopBar/index.js +3 -9
- package/dist/components/web-builder-puzzle-component/index.js +0 -3
- package/dist/components/web-builder-puzzle-component/mocks/mockForStory.js +0 -3
- package/dist/components/writer-puzzle-component/components/ElectionComponent.js +13 -30
- package/dist/components/writer-puzzle-component/components/FeedbackComponent.js +14 -30
- package/dist/components/writer-puzzle-component/components/FeedbackElement.js +2 -6
- package/dist/components/writer-puzzle-component/components/FinishedTextComponent.js +1 -6
- package/dist/components/writer-puzzle-component/components/FixedComponent.js +17 -52
- package/dist/components/writer-puzzle-component/components/SingleElection.js +13 -41
- package/dist/components/writer-puzzle-component/components/WriterPuzzleComponent.js +63 -145
- package/dist/components/writer-puzzle-component/index.js +0 -3
- package/dist/components/writer-puzzle-component/mocks/mockForStory.js +10 -7
- package/dist/components/zoom-test/components/ZoomTest.js +7 -25
- package/dist/components/zoom-test/index.js +0 -3
- package/dist/components/zoom-test/mocks/mockForStory.js +0 -4
- package/dist/helpers/LangIsRtl.js +0 -4
- package/dist/helpers/LightSet.js +0 -4
- package/dist/helpers/LodController.js +1 -10
- package/dist/helpers/deviceDetection.js +2 -5
- package/dist/helpers/drawLOD.js +11 -53
- package/dist/helpers/index.js +73 -102
- package/dist/helpers/lodStats.js +2 -10
- package/dist/helpers/mocker.js +1 -20
- package/dist/helpers/useEkho.js +64 -91
- package/dist/helpers/useGLB.js +5 -13
- package/dist/helpers/useStateMachine.js +254 -0
- package/dist/helpers/useTimeout.js +0 -6
- package/dist/helpers/useWindowSize.js +8 -22
- package/dist/index.js +0 -2
- package/dist/test/testSceneWrapper.js +0 -8
- package/package.json +3 -2
|
@@ -1,61 +1,42 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
|
-
|
|
10
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
-
|
|
12
9
|
var _SlotList = _interopRequireDefault(require("../../conversational-pro-component/components/SlotList"));
|
|
13
|
-
|
|
14
10
|
var _Message = _interopRequireDefault(require("../../conversational-pro-component/components/Message"));
|
|
15
|
-
|
|
16
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
|
|
18
12
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
19
|
-
|
|
20
13
|
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; }
|
|
21
|
-
|
|
22
14
|
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; }
|
|
23
|
-
|
|
24
15
|
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; }
|
|
25
|
-
|
|
26
|
-
function
|
|
27
|
-
|
|
16
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
17
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
18
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
28
19
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
29
|
-
|
|
30
20
|
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."); }
|
|
31
|
-
|
|
32
21
|
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); }
|
|
33
|
-
|
|
34
|
-
function
|
|
35
|
-
|
|
36
|
-
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; }
|
|
37
|
-
|
|
22
|
+
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; }
|
|
23
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
38
24
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
39
|
-
|
|
40
25
|
var ConversationalComponent = function ConversationalComponent(_ref) {
|
|
41
26
|
var _background$img;
|
|
42
|
-
|
|
43
27
|
var emitEvent = _ref.emitEvent,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
28
|
+
soundActions = _ref.soundActions,
|
|
29
|
+
messages = _ref.messages,
|
|
30
|
+
characters = _ref.characters,
|
|
31
|
+
alias = _ref.alias,
|
|
32
|
+
background = _ref.background,
|
|
33
|
+
lodSettings = _ref.lodSettings;
|
|
51
34
|
var _useState = (0, _react.useState)(0),
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
35
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
36
|
+
messageIndex = _useState2[0],
|
|
37
|
+
setMessageIndex = _useState2[1];
|
|
56
38
|
var _soundActions = _slicedToArray(soundActions, 1),
|
|
57
|
-
|
|
58
|
-
|
|
39
|
+
play = _soundActions[0];
|
|
59
40
|
var backgroundImage = (background === null || background === void 0 ? void 0 : (_background$img = background.img) === null || _background$img === void 0 ? void 0 : _background$img.url) || null;
|
|
60
41
|
var currentMessage = messages[messageIndex];
|
|
61
42
|
var parsedCharacters = characters.map(function (c, index) {
|
|
@@ -64,11 +45,9 @@ var ConversationalComponent = function ConversationalComponent(_ref) {
|
|
|
64
45
|
uid: index
|
|
65
46
|
});
|
|
66
47
|
});
|
|
67
|
-
|
|
68
48
|
var handleClickNext = function handleClickNext() {
|
|
69
49
|
var max = messages.length - 1;
|
|
70
50
|
play('click-ui');
|
|
71
|
-
|
|
72
51
|
if (messageIndex + 1 <= max) {
|
|
73
52
|
setMessageIndex(messageIndex + 1);
|
|
74
53
|
} else {
|
|
@@ -77,14 +56,12 @@ var ConversationalComponent = function ConversationalComponent(_ref) {
|
|
|
77
56
|
});
|
|
78
57
|
}
|
|
79
58
|
};
|
|
80
|
-
|
|
81
59
|
var handleClickBack = function handleClickBack() {
|
|
82
60
|
if (messageIndex > 0) {
|
|
83
61
|
setMessageIndex(messageIndex - 1);
|
|
84
62
|
play('click-ui');
|
|
85
63
|
}
|
|
86
64
|
};
|
|
87
|
-
|
|
88
65
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
89
66
|
className: "conversation--layer"
|
|
90
67
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -120,6 +97,5 @@ var ConversationalComponent = function ConversationalComponent(_ref) {
|
|
|
120
97
|
className: "icon-next"
|
|
121
98
|
}))))));
|
|
122
99
|
};
|
|
123
|
-
|
|
124
100
|
var _default = ConversationalComponent;
|
|
125
101
|
exports.default = _default;
|
|
@@ -4,10 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _ConversationalComponent = _interopRequireDefault(require("./components/ConversationalComponent"));
|
|
9
|
-
|
|
10
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
|
|
12
9
|
var _default = _ConversationalComponent.default;
|
|
13
10
|
exports.default = _default;
|
package/dist/components/conversational-pro-component/components/ConversationalProComponent.js
CHANGED
|
@@ -1,132 +1,95 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
|
-
|
|
10
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
-
|
|
12
9
|
var _SlotList = _interopRequireDefault(require("./SlotList"));
|
|
13
|
-
|
|
14
10
|
var _Message = _interopRequireDefault(require("./Message"));
|
|
15
|
-
|
|
16
11
|
var _decisionComponent = _interopRequireDefault(require("../../decision-component"));
|
|
17
|
-
|
|
18
12
|
var _useEkho = _interopRequireDefault(require("../../../helpers/useEkho"));
|
|
19
|
-
|
|
20
13
|
var _useTimeout2 = _interopRequireDefault(require("../../../helpers/useTimeout"));
|
|
21
|
-
|
|
22
14
|
var _LangIsRtl = _interopRequireDefault(require("../../../helpers/LangIsRtl"));
|
|
23
|
-
|
|
24
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
|
-
|
|
26
16
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
27
|
-
|
|
28
17
|
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
|
-
|
|
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
|
-
|
|
18
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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); }
|
|
32
19
|
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
|
-
|
|
34
20
|
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
|
-
|
|
36
|
-
function
|
|
37
|
-
|
|
21
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
22
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
23
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
38
24
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
39
|
-
|
|
40
25
|
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
26
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
43
|
-
|
|
44
27
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
45
|
-
|
|
46
28
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
47
|
-
|
|
48
29
|
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
|
-
|
|
50
30
|
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); }
|
|
51
|
-
|
|
52
|
-
function
|
|
53
|
-
|
|
54
|
-
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; }
|
|
55
|
-
|
|
31
|
+
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; }
|
|
32
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
56
33
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
57
|
-
|
|
58
34
|
var characterMs = 75;
|
|
59
35
|
var minMs = 1400;
|
|
60
|
-
|
|
61
36
|
var ConversationProViewer = function ConversationProViewer(_ref) {
|
|
62
37
|
var _background$img, _currentLineData$slot3, _currentMessage$text;
|
|
63
|
-
|
|
64
38
|
var keyboardControl = _ref.keyboardControl,
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
39
|
+
emitEvent = _ref.emitEvent,
|
|
40
|
+
pause = _ref.pause,
|
|
41
|
+
lines = _ref.lines,
|
|
42
|
+
edges = _ref.edges,
|
|
43
|
+
characters = _ref.characters,
|
|
44
|
+
actors = _ref.actors,
|
|
45
|
+
background = _ref.background,
|
|
46
|
+
soundActions = _ref.soundActions,
|
|
47
|
+
lodSettings = _ref.lodSettings,
|
|
48
|
+
autoPlay = _ref.autoPlay,
|
|
49
|
+
progress = _ref.progress;
|
|
76
50
|
var defaultLine = (progress === null || progress === void 0 ? void 0 : progress.line) || 0;
|
|
77
|
-
|
|
78
51
|
var _useState = (0, _react.useState)(false),
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
52
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
53
|
+
mounted = _useState2[0],
|
|
54
|
+
setMounted = _useState2[1];
|
|
83
55
|
var _useState3 = (0, _react.useState)(true),
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
56
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
57
|
+
started = _useState4[0],
|
|
58
|
+
setStarted = _useState4[1];
|
|
88
59
|
var _useState5 = (0, _react.useState)(!!autoPlay),
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
60
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
61
|
+
automatic = _useState6[0],
|
|
62
|
+
setAutomatic = _useState6[1];
|
|
93
63
|
var _useState7 = (0, _react.useState)(false),
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
64
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
65
|
+
audioFailed = _useState8[0],
|
|
66
|
+
setAudioFailed = _useState8[1];
|
|
98
67
|
var _useState9 = (0, _react.useState)(defaultLine),
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
68
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
69
|
+
currentLine = _useState10[0],
|
|
70
|
+
setCurrentLine = _useState10[1];
|
|
103
71
|
var _useState11 = (0, _react.useState)(false),
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
72
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
|
73
|
+
ttsStarted = _useState12[0],
|
|
74
|
+
setTTsStart = _useState12[1];
|
|
108
75
|
var _soundActions = _slicedToArray(soundActions, 1),
|
|
109
|
-
|
|
110
|
-
|
|
76
|
+
playSound = _soundActions[0];
|
|
111
77
|
var _useTimeout = (0, _useTimeout2.default)(),
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
78
|
+
start = _useTimeout.start,
|
|
79
|
+
stop = _useTimeout.stop;
|
|
115
80
|
var backgroundImage = (background === null || background === void 0 ? void 0 : (_background$img = background.img) === null || _background$img === void 0 ? void 0 : _background$img.url) || null;
|
|
116
81
|
var currentLineData = lines[currentLine];
|
|
117
82
|
var voiceOver = currentLineData.voiceOver,
|
|
118
|
-
|
|
83
|
+
decision = currentLineData.decision;
|
|
119
84
|
var voiceOverSlots = [];
|
|
120
85
|
var isBranched = !!edges;
|
|
121
86
|
var isVoiceOver = voiceOver || currentLineData.type === 'conversationalNarration';
|
|
122
87
|
var isDecision = decision || currentLineData.type === 'conversationalDecision';
|
|
123
88
|
var isFlex = currentLineData.flex;
|
|
124
|
-
|
|
125
89
|
var _useState13 = (0, _react.useState)([]),
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
90
|
+
_useState14 = _slicedToArray(_useState13, 2),
|
|
91
|
+
edgesHistory = _useState14[0],
|
|
92
|
+
setEdgesHistory = _useState14[1];
|
|
130
93
|
var lastNodeId = (0, _react.useMemo)(function () {
|
|
131
94
|
return edgesHistory[edgesHistory.length - 1];
|
|
132
95
|
}, [edgesHistory]);
|
|
@@ -139,24 +102,20 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
|
|
|
139
102
|
var lastLine = lines.find(function (line) {
|
|
140
103
|
return line.id === (lastEdge === null || lastEdge === void 0 ? void 0 : lastEdge.fromId);
|
|
141
104
|
});
|
|
142
|
-
|
|
143
105
|
if (!lastNodeId && (progress === null || progress === void 0 ? void 0 : progress.line) >= 0) {
|
|
144
106
|
return {
|
|
145
107
|
decision: true
|
|
146
108
|
};
|
|
147
109
|
}
|
|
148
|
-
|
|
149
110
|
return lastLine;
|
|
150
111
|
}, [edges, lines, lastNodeId, progress === null || progress === void 0 ? void 0 : progress.line]);
|
|
151
112
|
var previousLineWasDecision = (0, _react.useCallback)(function () {
|
|
152
113
|
if (isBranched) {
|
|
153
114
|
// if we have edges, we need to check if the previous line was a decision
|
|
154
115
|
var _lastLine = findLastLineBranched();
|
|
155
|
-
|
|
156
116
|
return _lastLine === null || _lastLine === void 0 ? void 0 : _lastLine.decision;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
|
|
117
|
+
}
|
|
118
|
+
// if there is no branching, the previous line is the previous one
|
|
160
119
|
var lastLine = lines[currentLine - 1] ? lines[currentLine - 1] : {};
|
|
161
120
|
return currentLine > 0 && (lastLine === null || lastLine === void 0 ? void 0 : lastLine.decision);
|
|
162
121
|
}, [isBranched, findLastLineBranched, lines, currentLine]);
|
|
@@ -168,22 +127,18 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
|
|
|
168
127
|
}, [emitEvent]);
|
|
169
128
|
var currentMessage = (0, _react.useMemo)(function () {
|
|
170
129
|
var _currentLineData$slot, _currentLineData$slot2;
|
|
171
|
-
|
|
172
130
|
if (isDecision) return {};
|
|
173
|
-
|
|
174
131
|
if (isVoiceOver) {
|
|
175
132
|
return currentLineData;
|
|
176
133
|
}
|
|
177
|
-
|
|
178
134
|
var message = currentLineData === null || currentLineData === void 0 ? void 0 : (_currentLineData$slot = currentLineData.slots) === null || _currentLineData$slot === void 0 ? void 0 : _currentLineData$slot.find(function (slot) {
|
|
179
135
|
return slot.uid && slot.talking;
|
|
180
136
|
});
|
|
181
|
-
|
|
182
137
|
if (message) {
|
|
183
138
|
return message;
|
|
184
|
-
}
|
|
185
|
-
|
|
139
|
+
}
|
|
186
140
|
|
|
141
|
+
// Old conversational schema
|
|
187
142
|
return currentLineData === null || currentLineData === void 0 ? void 0 : (_currentLineData$slot2 = currentLineData.slots) === null || _currentLineData$slot2 === void 0 ? void 0 : _currentLineData$slot2.find(function (slot) {
|
|
188
143
|
return slot.uid && slot.text;
|
|
189
144
|
});
|
|
@@ -197,8 +152,9 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
|
|
|
197
152
|
flex: isFlex,
|
|
198
153
|
pause: pause,
|
|
199
154
|
emitEvent: emitEvent
|
|
200
|
-
};
|
|
155
|
+
};
|
|
201
156
|
|
|
157
|
+
// Last line with slots
|
|
202
158
|
var leftWithSlots = lines.slice(0, currentLine + 1).reverse().find(function (line) {
|
|
203
159
|
return line.slots;
|
|
204
160
|
});
|
|
@@ -207,35 +163,29 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
|
|
|
207
163
|
}).length);
|
|
208
164
|
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);
|
|
209
165
|
var currentSlots = [];
|
|
210
|
-
|
|
211
166
|
if (currentLineData.slots) {
|
|
212
167
|
currentSlots = currentLineData.slots;
|
|
213
168
|
} else if (leftWithSlots) {
|
|
214
169
|
currentSlots = leftWithSlots.slots;
|
|
215
170
|
}
|
|
216
|
-
|
|
217
171
|
var currentCharacters = currentSlots.filter(function (slot) {
|
|
218
172
|
return slot.uid;
|
|
219
173
|
}).map(function (slot) {
|
|
220
174
|
var character = (characters || actors || []).find(function (c) {
|
|
221
175
|
return c.uid === slot.uid;
|
|
222
176
|
});
|
|
223
|
-
|
|
224
177
|
if (character) {
|
|
225
178
|
slot.resource = character.resource;
|
|
226
179
|
slot.type = character.type;
|
|
227
180
|
}
|
|
228
|
-
|
|
229
181
|
if (!slot.resource) slot.resource = {};
|
|
230
182
|
return slot;
|
|
231
183
|
});
|
|
232
|
-
|
|
233
184
|
if (isVoiceOver) {
|
|
234
185
|
var rightWithSlots = lines.slice(currentLine).find(function (line) {
|
|
235
186
|
return line.slots;
|
|
236
187
|
});
|
|
237
188
|
var lineWithSlots = !leftWithSlots ? rightWithSlots : leftWithSlots;
|
|
238
|
-
|
|
239
189
|
if (lineWithSlots) {
|
|
240
190
|
voiceOverSlots = lineWithSlots.slots;
|
|
241
191
|
isFlex = lineWithSlots.flex;
|
|
@@ -245,12 +195,10 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
|
|
|
245
195
|
var indx = currentCharacters.findIndex(function (char) {
|
|
246
196
|
return char.uid === slot.uid;
|
|
247
197
|
});
|
|
248
|
-
|
|
249
198
|
if (indx >= 0) {
|
|
250
199
|
currentCharacters[indx].emotion = slot.emotion;
|
|
251
200
|
}
|
|
252
201
|
});
|
|
253
|
-
|
|
254
202
|
if (currentMessage && currentMessage.uid) {
|
|
255
203
|
var notFlexedPosition = currentLineData.slots.findIndex(function (char) {
|
|
256
204
|
return char.uid === currentMessage.uid;
|
|
@@ -264,7 +212,6 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
|
|
|
264
212
|
currentMessage.position = isFlex ? flexedPosition : notFlexedPosition;
|
|
265
213
|
}
|
|
266
214
|
}
|
|
267
|
-
|
|
268
215
|
var finishConversation = (0, _react.useCallback)(function () {
|
|
269
216
|
emitEvent({
|
|
270
217
|
type: 'success'
|
|
@@ -278,12 +225,10 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
|
|
|
278
225
|
var currentEdge = optionsEdges.find(function (edge) {
|
|
279
226
|
return parseInt(edge.fromPointIndex) === currentId;
|
|
280
227
|
});
|
|
281
|
-
|
|
282
228
|
if (currentEdge) {
|
|
283
229
|
var destinationEdge = lines.findIndex(function (l) {
|
|
284
230
|
return l.id === currentEdge.toId;
|
|
285
231
|
});
|
|
286
|
-
|
|
287
232
|
if (currentEdge.fromId === currentEdge.toId) {
|
|
288
233
|
reset();
|
|
289
234
|
} else if (destinationEdge >= 0) {
|
|
@@ -310,20 +255,16 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
|
|
|
310
255
|
var foundEdge = foundEdges.length === 1 ? foundEdges[0] : foundEdges.find(function (edge) {
|
|
311
256
|
return edge[keys[1]] === lastNodeId;
|
|
312
257
|
});
|
|
313
|
-
|
|
314
258
|
if (!(foundEdge !== null && foundEdge !== void 0 && foundEdge[keys[0]])) {
|
|
315
259
|
return;
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
|
|
260
|
+
}
|
|
261
|
+
// if going backwards, we need to remove the last node from the history
|
|
319
262
|
if (!forward) {
|
|
320
263
|
setEdgesHistory(edgesHistory.slice(0, -1));
|
|
321
264
|
}
|
|
322
|
-
|
|
323
265
|
var destination = lines.findIndex(function (line) {
|
|
324
266
|
return line.id === foundEdge[keys[1]];
|
|
325
267
|
});
|
|
326
|
-
|
|
327
268
|
if (destination >= 0) {
|
|
328
269
|
setCurrentLine(destination);
|
|
329
270
|
emitEvent({
|
|
@@ -342,7 +283,6 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
|
|
|
342
283
|
setEdgesHistory([].concat(_toConsumableArray(edgesHistory), [currentLineData.id]));
|
|
343
284
|
setStarted(false);
|
|
344
285
|
setAudioFailed(false);
|
|
345
|
-
|
|
346
286
|
if (isBranched) {
|
|
347
287
|
if (choice) {
|
|
348
288
|
handleDecisionBranch(choice, reset);
|
|
@@ -352,7 +292,6 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
|
|
|
352
292
|
} else {
|
|
353
293
|
var line = currentLine;
|
|
354
294
|
var maxLine = lines.length - 1;
|
|
355
|
-
|
|
356
295
|
if (line + 1 <= maxLine) {
|
|
357
296
|
var next = line + 1;
|
|
358
297
|
setCurrentLine(next);
|
|
@@ -368,17 +307,14 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
|
|
|
368
307
|
isLast = true;
|
|
369
308
|
}
|
|
370
309
|
}
|
|
371
|
-
|
|
372
310
|
if (!isLast) {
|
|
373
311
|
setStarted(true);
|
|
374
312
|
}
|
|
375
313
|
}, [emitEvent, currentLine, currentLineData.decision, currentLineData.id, finishConversation, handleBranchDirection, handleDecisionBranch, isBranched, lines.length, edgesHistory]);
|
|
376
|
-
|
|
377
314
|
var handleClickBack = function handleClickBack() {
|
|
378
315
|
setStarted(false);
|
|
379
316
|
setTTsStart(false);
|
|
380
317
|
setAudioFailed(false);
|
|
381
|
-
|
|
382
318
|
if (isBranched) {
|
|
383
319
|
handleBranchDirection(false);
|
|
384
320
|
} else if (!previousLineWasDecision()) {
|
|
@@ -391,23 +327,18 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
|
|
|
391
327
|
}
|
|
392
328
|
});
|
|
393
329
|
}
|
|
394
|
-
|
|
395
330
|
setStarted(true);
|
|
396
331
|
};
|
|
397
|
-
|
|
398
332
|
var isEndNode = (0, _react.useCallback)(function () {
|
|
399
333
|
if (isBranched) {
|
|
400
334
|
return currentLineData && currentLineData.type !== 'conversationalDecision' && !edges.find(function (edge) {
|
|
401
335
|
return edge.fromId === currentLineData.id;
|
|
402
336
|
});
|
|
403
337
|
}
|
|
404
|
-
|
|
405
338
|
return currentLine === lines.length - 1;
|
|
406
339
|
}, [currentLine, currentLineData, edges, isBranched, lines.length]);
|
|
407
|
-
|
|
408
340
|
var manualClickNext = function manualClickNext() {
|
|
409
341
|
playSound('click-ui');
|
|
410
|
-
|
|
411
342
|
if (isEndNode()) {
|
|
412
343
|
finishConversation();
|
|
413
344
|
} else {
|
|
@@ -415,13 +346,11 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
|
|
|
415
346
|
handleClickNext();
|
|
416
347
|
}
|
|
417
348
|
};
|
|
418
|
-
|
|
419
349
|
var manualClickBack = function manualClickBack() {
|
|
420
350
|
playSound('click-ui');
|
|
421
351
|
setAutomatic(false);
|
|
422
352
|
handleClickBack();
|
|
423
353
|
};
|
|
424
|
-
|
|
425
354
|
var autoplayCond = automatic && !isDecision && !pause;
|
|
426
355
|
var disableBackButton = (0, _react.useMemo)(function () {
|
|
427
356
|
return currentLine === 0 || previousLineWasDecision();
|
|
@@ -439,7 +368,6 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
|
|
|
439
368
|
pauseTTS: pause,
|
|
440
369
|
onStart: function onStart() {
|
|
441
370
|
var _currentMessage$emoti;
|
|
442
|
-
|
|
443
371
|
if (currentMessage !== null && currentMessage !== void 0 && (_currentMessage$emoti = currentMessage.emotion) !== null && _currentMessage$emoti !== void 0 && _currentMessage$emoti.includes('think')) return;
|
|
444
372
|
setTTsStart(true);
|
|
445
373
|
},
|
|
@@ -448,7 +376,6 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
|
|
|
448
376
|
},
|
|
449
377
|
onFinish: function onFinish() {
|
|
450
378
|
setTTsStart(false);
|
|
451
|
-
|
|
452
379
|
if (autoplayCond) {
|
|
453
380
|
handleClickNext();
|
|
454
381
|
}
|
|
@@ -456,22 +383,20 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
|
|
|
456
383
|
});
|
|
457
384
|
(0, _react.useEffect)(function () {
|
|
458
385
|
var _currentMessage$emoti2;
|
|
459
|
-
|
|
460
386
|
var timeout;
|
|
461
387
|
if (isDecision) return function () {};
|
|
462
|
-
|
|
463
388
|
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'))) {
|
|
464
389
|
setTTsStart(true);
|
|
465
390
|
timeout = setTimeout(function () {
|
|
466
391
|
setTTsStart(false);
|
|
467
392
|
}, autoPlayTime < minMs ? minMs : autoPlayTime);
|
|
468
393
|
}
|
|
469
|
-
|
|
470
394
|
return function () {
|
|
471
395
|
if (timeout) clearTimeout(timeout);
|
|
472
396
|
};
|
|
473
|
-
}, [audioFailed, currentLineData, currentMessage === null || currentMessage === void 0 ? void 0 : currentMessage.emotion, autoPlayTime, isDecision]);
|
|
397
|
+
}, [audioFailed, currentLineData, currentMessage === null || currentMessage === void 0 ? void 0 : currentMessage.emotion, autoPlayTime, isDecision]);
|
|
474
398
|
|
|
399
|
+
// Autoplay logic
|
|
475
400
|
(0, _react.useEffect)(function () {
|
|
476
401
|
if (autoplayCond && ((currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.audioType) === 'none' || audioFailed)) {
|
|
477
402
|
// if it's not last node
|
|
@@ -479,32 +404,28 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
|
|
|
479
404
|
start(handleClickNext, autoPlayTime < minMs ? minMs : autoPlayTime);
|
|
480
405
|
}
|
|
481
406
|
}
|
|
482
|
-
|
|
483
407
|
return function () {
|
|
484
408
|
stop();
|
|
485
409
|
};
|
|
486
|
-
}, [currentMessage, start, stop, handleClickNext, currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.audioType, autoplayCond, audioFailed, lines, isEndNode, autoPlayTime]);
|
|
410
|
+
}, [currentMessage, start, stop, handleClickNext, currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.audioType, autoplayCond, audioFailed, lines, isEndNode, autoPlayTime]);
|
|
487
411
|
|
|
412
|
+
// Calculate start node
|
|
488
413
|
(0, _react.useEffect)(function () {
|
|
489
414
|
if (isBranched && !mounted) {
|
|
490
415
|
var defaultBranch = progress === null || progress === void 0 ? void 0 : progress.line;
|
|
491
|
-
|
|
492
416
|
if (defaultBranch >= 0) {
|
|
493
417
|
setMounted(true);
|
|
494
418
|
setCurrentLine(defaultBranch);
|
|
495
419
|
return;
|
|
496
420
|
}
|
|
497
|
-
|
|
498
421
|
var startNodes = lines.filter(function (node) {
|
|
499
422
|
return !edges.find(function (edge) {
|
|
500
423
|
return edge.toId === node.id;
|
|
501
424
|
});
|
|
502
425
|
});
|
|
503
|
-
|
|
504
426
|
if (startNodes.length) {
|
|
505
427
|
var initialNode = startNodes[0];
|
|
506
428
|
var newInitiaIndexlNode = lines.indexOf(initialNode);
|
|
507
|
-
|
|
508
429
|
if (newInitiaIndexlNode >= 0) {
|
|
509
430
|
setMounted(true);
|
|
510
431
|
setCurrentLine(newInitiaIndexlNode);
|
|
@@ -513,7 +434,6 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
|
|
|
513
434
|
}
|
|
514
435
|
}, [edges, isBranched, lines, mounted, progress === null || progress === void 0 ? void 0 : progress.line]);
|
|
515
436
|
keyboardControl(isDecision || disableBackButton ? null : manualClickBack, isDecision ? null : manualClickNext);
|
|
516
|
-
|
|
517
437
|
var decisionPayload = _objectSpread(_objectSpread({}, currentLineData.payload), {}, {
|
|
518
438
|
required: !isBranched,
|
|
519
439
|
branched: isBranched,
|
|
@@ -528,11 +448,9 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
|
|
|
528
448
|
slots: !leftWithSlots ? [] : leftWithSlots.slots
|
|
529
449
|
}
|
|
530
450
|
});
|
|
531
|
-
|
|
532
451
|
if (isDecision) {
|
|
533
452
|
return /*#__PURE__*/_react.default.createElement(_decisionComponent.default, decisionPayload);
|
|
534
453
|
}
|
|
535
|
-
|
|
536
454
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
537
455
|
className: "conversation--layer"
|
|
538
456
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -567,7 +485,6 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
|
|
|
567
485
|
className: (0, _LangIsRtl.default)() ? 'icon-back' : 'icon-next'
|
|
568
486
|
}))))));
|
|
569
487
|
};
|
|
570
|
-
|
|
571
488
|
ConversationProViewer.defaultProps = {
|
|
572
489
|
background: {},
|
|
573
490
|
emitEvent: function emitEvent() {},
|