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