@gamelearn/arcade-components 2.27.0 → 2.29.2
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 +16 -42
- 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 +37 -81
- 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 +26 -48
- 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 +34 -52
- 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 +12 -13
- 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 +257 -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
package/dist/helpers/lodStats.js
CHANGED
|
@@ -11,35 +11,28 @@ var divideby16 = 0;
|
|
|
11
11
|
var divideby4 = 0;
|
|
12
12
|
var original = 0;
|
|
13
13
|
var style = 'float:left;margin:5px;padding:5px;';
|
|
14
|
-
|
|
15
14
|
function formatBytes(a) {
|
|
16
15
|
var b = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2;
|
|
17
|
-
|
|
18
16
|
if (a === 0) {
|
|
19
17
|
return '0 Bytes';
|
|
20
18
|
}
|
|
21
|
-
|
|
22
19
|
var c = b < 0 ? 0 : b;
|
|
23
20
|
var d = Math.floor(Math.log(a) / Math.log(1024));
|
|
24
21
|
return "".concat(parseFloat((a / Math.pow(1024, d)).toFixed(c)), " ").concat(['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'][d]);
|
|
25
22
|
}
|
|
26
|
-
|
|
27
23
|
var lodStats = function lodStats(obj) {
|
|
28
24
|
if (!lodStatsElement) {
|
|
29
25
|
var root = document.getElementById('root');
|
|
30
26
|
var previous = document.getElementById('lodStats');
|
|
31
|
-
|
|
32
27
|
if (previous) {
|
|
33
28
|
root.removeChild(previous);
|
|
34
29
|
}
|
|
35
|
-
|
|
36
30
|
var div = document.createElement('div');
|
|
37
31
|
div.style = "border-radius:5px;color:white; background-color:black;\n position: fixed; top: 0px; left: 100px; opacity: 0.5; z-index: 10001;";
|
|
38
32
|
div.id = 'lodStats';
|
|
39
33
|
root.appendChild(div);
|
|
40
34
|
lodStatsElement = div;
|
|
41
35
|
}
|
|
42
|
-
|
|
43
36
|
if (obj.reset) {
|
|
44
37
|
lodStatsElement.innerHTML = '';
|
|
45
38
|
lodStatsElement = null;
|
|
@@ -53,11 +46,10 @@ var lodStats = function lodStats(obj) {
|
|
|
53
46
|
divideby64 += obj.divideby64 ? obj.divideby64 : 0;
|
|
54
47
|
divideby16 += obj.divideby16 ? obj.divideby16 : 0;
|
|
55
48
|
divideby4 += obj.divideby4 ? obj.divideby4 : 0;
|
|
56
|
-
original += obj.original ? obj.original : 0;
|
|
57
|
-
|
|
49
|
+
original += obj.original ? obj.original : 0;
|
|
50
|
+
// rootProjection.innerHTML = `Geo: ${geo} d64: ${divideby64} d16: ${divideby16} d4: ${divideby4} original: ${original}`;
|
|
58
51
|
lodStatsElement.innerHTML = "\n <div style=\"".concat(style, "\"> \n <div>Geometries</div>\n <div>").concat(formatBytes(geo), "</div>\n </div>\n <div style=\"").concat(style, "\"> \n <div style=\"color:red\">DivideBy64</div>\n <div>").concat(formatBytes(divideby64), "</div>\n </div>\n <div style=\"").concat(style, "\"> \n <div style=\"color:green\">DivideBy16</div>\n <div>").concat(formatBytes(divideby16), "</div>\n </div>\n <div style=\"").concat(style, "\"> \n <div style=\"color:blue\">DivideBy4</div>\n <div>").concat(formatBytes(divideby4), "</div>\n </div>\n <div style=\"").concat(style, "\"> \n <div>Original</div>\n <div>").concat(formatBytes(original), "</div>\n </div>\n ");
|
|
59
52
|
}
|
|
60
53
|
};
|
|
61
|
-
|
|
62
54
|
var _default = lodStats;
|
|
63
55
|
exports.default = _default;
|
package/dist/helpers/mocker.js
CHANGED
|
@@ -4,18 +4,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.translate = exports.soundActions = exports.setShowPoints = exports.onFinish = exports.noopSoundActions = exports.keyboardControl = exports.getSpeech = exports.functionOnClose = exports.emitEvent = void 0;
|
|
7
|
-
|
|
8
7
|
/* eslint-disable no-console */
|
|
9
|
-
|
|
10
8
|
/* eslint-disable no-prototype-builtins */
|
|
11
9
|
var emitEvent = function emitEvent(_ref) {
|
|
12
10
|
var type = _ref.type,
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
payload = _ref.payload;
|
|
15
12
|
if (type === 'translate') {
|
|
16
13
|
return payload;
|
|
17
14
|
}
|
|
18
|
-
|
|
19
15
|
if (type === 'loadIndicators') {
|
|
20
16
|
return {
|
|
21
17
|
score: [{
|
|
@@ -73,11 +69,9 @@ var emitEvent = function emitEvent(_ref) {
|
|
|
73
69
|
grade: undefined
|
|
74
70
|
};
|
|
75
71
|
}
|
|
76
|
-
|
|
77
72
|
console.log('Emit event called:', type, 'payload:', payload);
|
|
78
73
|
return null;
|
|
79
74
|
};
|
|
80
|
-
|
|
81
75
|
exports.emitEvent = emitEvent;
|
|
82
76
|
var noopSoundActions = [function () {}, function () {}];
|
|
83
77
|
exports.noopSoundActions = noopSoundActions;
|
|
@@ -88,7 +82,6 @@ var audio = {
|
|
|
88
82
|
};
|
|
89
83
|
var soundActions = [function (sound) {
|
|
90
84
|
console.log('PlaySound called :', sound);
|
|
91
|
-
|
|
92
85
|
if (sound && audio.hasOwnProperty(sound)) {
|
|
93
86
|
audio[sound].play();
|
|
94
87
|
} else if (sound && sound.includes('http')) {
|
|
@@ -97,39 +90,27 @@ var soundActions = [function (sound) {
|
|
|
97
90
|
}
|
|
98
91
|
}, function () {}, function () {}, function () {}];
|
|
99
92
|
exports.soundActions = soundActions;
|
|
100
|
-
|
|
101
93
|
var setShowPoints = function setShowPoints() {
|
|
102
94
|
var score = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
103
95
|
console.log('score', score);
|
|
104
96
|
};
|
|
105
|
-
|
|
106
97
|
exports.setShowPoints = setShowPoints;
|
|
107
|
-
|
|
108
98
|
var getSpeech = function getSpeech(payload) {
|
|
109
99
|
console.log('getSpeech', payload);
|
|
110
100
|
};
|
|
111
|
-
|
|
112
101
|
exports.getSpeech = getSpeech;
|
|
113
|
-
|
|
114
102
|
var translate = function translate(payload) {
|
|
115
103
|
return payload;
|
|
116
104
|
};
|
|
117
|
-
|
|
118
105
|
exports.translate = translate;
|
|
119
|
-
|
|
120
106
|
var functionOnClose = function functionOnClose() {
|
|
121
107
|
console.log('closing this');
|
|
122
108
|
};
|
|
123
|
-
|
|
124
109
|
exports.functionOnClose = functionOnClose;
|
|
125
|
-
|
|
126
110
|
var onFinish = function onFinish() {
|
|
127
111
|
var component = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'a component';
|
|
128
112
|
console.log('you just called onfinish from...', component);
|
|
129
113
|
};
|
|
130
|
-
|
|
131
114
|
exports.onFinish = onFinish;
|
|
132
|
-
|
|
133
115
|
var keyboardControl = function keyboardControl() {};
|
|
134
|
-
|
|
135
116
|
exports.keyboardControl = keyboardControl;
|
package/dist/helpers/useEkho.js
CHANGED
|
@@ -1,68 +1,55 @@
|
|
|
1
1
|
"use strict";
|
|
2
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); }
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports.default = void 0;
|
|
7
|
-
|
|
8
8
|
var _react = require("react");
|
|
9
|
-
|
|
9
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
10
10
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
11
|
-
|
|
12
11
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
13
|
-
|
|
14
12
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
15
|
-
|
|
16
13
|
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."); }
|
|
17
|
-
|
|
18
14
|
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); }
|
|
19
|
-
|
|
20
|
-
function
|
|
21
|
-
|
|
22
|
-
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; }
|
|
23
|
-
|
|
15
|
+
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; }
|
|
16
|
+
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
17
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
25
|
-
|
|
26
18
|
var noop = function noop() {};
|
|
27
|
-
/** Custom hook for use TTS and audio in the components */
|
|
28
|
-
|
|
29
19
|
|
|
20
|
+
/** Custom hook for use TTS and audio in the components */
|
|
30
21
|
var useEkho = function useEkho(_ref) {
|
|
31
22
|
var voice = _ref.voice,
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
23
|
+
text = _ref.text,
|
|
24
|
+
audioType = _ref.audioType,
|
|
25
|
+
_ref$loop = _ref.loop,
|
|
26
|
+
loop = _ref$loop === void 0 ? false : _ref$loop,
|
|
27
|
+
_ref$started = _ref.started,
|
|
28
|
+
started = _ref$started === void 0 ? true : _ref$started,
|
|
29
|
+
_ref$slide = _ref.slide,
|
|
30
|
+
slide = _ref$slide === void 0 ? 0 : _ref$slide,
|
|
31
|
+
audio = _ref.audio,
|
|
32
|
+
soundActions = _ref.soundActions,
|
|
33
|
+
emitEvent = _ref.emitEvent,
|
|
34
|
+
_ref$volume = _ref.volume,
|
|
35
|
+
volume = _ref$volume === void 0 ? 0.5 : _ref$volume,
|
|
36
|
+
_ref$onFinish = _ref.onFinish,
|
|
37
|
+
onFinish = _ref$onFinish === void 0 ? noop : _ref$onFinish,
|
|
38
|
+
_ref$onError = _ref.onError,
|
|
39
|
+
onError = _ref$onError === void 0 ? noop : _ref$onError,
|
|
40
|
+
_ref$onStart = _ref.onStart,
|
|
41
|
+
onStart = _ref$onStart === void 0 ? noop : _ref$onStart,
|
|
42
|
+
pauseTTS = _ref.pauseTTS;
|
|
53
43
|
var _soundActions = _slicedToArray(soundActions, 4),
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
44
|
+
playSound = _soundActions[0],
|
|
45
|
+
stop = _soundActions[1],
|
|
46
|
+
pause = _soundActions[2],
|
|
47
|
+
resume = _soundActions[3];
|
|
59
48
|
var noAudio = !audio && !voice;
|
|
60
|
-
|
|
61
49
|
var _useState = (0, _react.useState)(false),
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
50
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
51
|
+
isMounted = _useState2[0],
|
|
52
|
+
setIsMounted = _useState2[1];
|
|
66
53
|
var currentPlaying = (0, _react.useRef)({
|
|
67
54
|
url: '',
|
|
68
55
|
cc: 'tts'
|
|
@@ -72,34 +59,29 @@ var useEkho = function useEkho(_ref) {
|
|
|
72
59
|
type: 'translate',
|
|
73
60
|
payload: id
|
|
74
61
|
});
|
|
75
|
-
}, [emitEvent]);
|
|
62
|
+
}, [emitEvent]);
|
|
76
63
|
|
|
64
|
+
// Get translated voices, todo: translate this in arcade translateProps i18n.helper.js
|
|
77
65
|
var getVoice = (0, _react.useCallback)(function (_ref2) {
|
|
78
66
|
var id = _ref2.id,
|
|
79
|
-
|
|
80
|
-
|
|
67
|
+
_ref2$type = _ref2.type,
|
|
68
|
+
type = _ref2$type === void 0 ? 'base' : _ref2$type;
|
|
81
69
|
var usedVoices = translate('usedVoices');
|
|
82
70
|
var gameChars = translate('gameCharacters');
|
|
83
|
-
|
|
84
71
|
if (type === 'base') {
|
|
85
72
|
return usedVoices === null || usedVoices === void 0 ? void 0 : usedVoices[id];
|
|
86
73
|
}
|
|
87
|
-
|
|
88
74
|
if (type === 'character') {
|
|
89
75
|
var _gameChars$id;
|
|
90
|
-
|
|
91
76
|
return gameChars === null || gameChars === void 0 ? void 0 : (_gameChars$id = gameChars[id]) === null || _gameChars$id === void 0 ? void 0 : _gameChars$id.voiceId;
|
|
92
77
|
}
|
|
93
|
-
|
|
94
78
|
return null;
|
|
95
79
|
}, [translate]);
|
|
96
80
|
var setCurrentPlaying = (0, _react.useCallback)(function (url) {
|
|
97
81
|
var cc = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'tts';
|
|
98
|
-
|
|
99
82
|
if (currentPlaying.current.url === url && slide === currentPlaying.current.slide) {
|
|
100
83
|
return;
|
|
101
84
|
}
|
|
102
|
-
|
|
103
85
|
currentPlaying.current = {
|
|
104
86
|
url: url,
|
|
105
87
|
cc: cc,
|
|
@@ -108,47 +90,38 @@ var useEkho = function useEkho(_ref) {
|
|
|
108
90
|
playSound(url, cc, loop, volume, onFinish, onStart);
|
|
109
91
|
}, [slide, playSound, loop, volume, onFinish, onStart]);
|
|
110
92
|
var playSpeech = (0, _react.useCallback)( /*#__PURE__*/function () {
|
|
111
|
-
var _ref3 = _asyncToGenerator( /*#__PURE__*/
|
|
93
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(payload) {
|
|
112
94
|
var url;
|
|
113
|
-
return
|
|
114
|
-
while (1) {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
_context.next = 7;
|
|
119
|
-
break;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
_context.next = 3;
|
|
123
|
-
return emitEvent({
|
|
124
|
-
type: 'getSpeech',
|
|
125
|
-
payload: payload
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
case 3:
|
|
129
|
-
url = _context.sent;
|
|
130
|
-
|
|
131
|
-
if (!url) {
|
|
132
|
-
onError();
|
|
133
|
-
} else {
|
|
134
|
-
setCurrentPlaying(url);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
_context.next = 8;
|
|
95
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
96
|
+
while (1) switch (_context.prev = _context.next) {
|
|
97
|
+
case 0:
|
|
98
|
+
if (!(isMounted && payload.voiceId && payload.text)) {
|
|
99
|
+
_context.next = 7;
|
|
138
100
|
break;
|
|
139
|
-
|
|
140
|
-
|
|
101
|
+
}
|
|
102
|
+
_context.next = 3;
|
|
103
|
+
return emitEvent({
|
|
104
|
+
type: 'getSpeech',
|
|
105
|
+
payload: payload
|
|
106
|
+
});
|
|
107
|
+
case 3:
|
|
108
|
+
url = _context.sent;
|
|
109
|
+
if (!url) {
|
|
141
110
|
onError();
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
111
|
+
} else {
|
|
112
|
+
setCurrentPlaying(url);
|
|
113
|
+
}
|
|
114
|
+
_context.next = 8;
|
|
115
|
+
break;
|
|
116
|
+
case 7:
|
|
117
|
+
onError();
|
|
118
|
+
case 8:
|
|
119
|
+
case "end":
|
|
120
|
+
return _context.stop();
|
|
147
121
|
}
|
|
148
122
|
}, _callee);
|
|
149
123
|
}));
|
|
150
|
-
|
|
151
|
-
return function (_x) {
|
|
124
|
+
return function (_x2) {
|
|
152
125
|
return _ref3.apply(this, arguments);
|
|
153
126
|
};
|
|
154
127
|
}(), [emitEvent, isMounted, onError, setCurrentPlaying]);
|
|
@@ -156,8 +129,9 @@ var useEkho = function useEkho(_ref) {
|
|
|
156
129
|
if (currentPlaying.current.url) {
|
|
157
130
|
stop(currentPlaying.current.cc);
|
|
158
131
|
}
|
|
159
|
-
}, [stop]);
|
|
132
|
+
}, [stop]);
|
|
160
133
|
|
|
134
|
+
// Setted when is mounted
|
|
161
135
|
(0, _react.useEffect)(function () {
|
|
162
136
|
setIsMounted(true);
|
|
163
137
|
return function () {
|
|
@@ -194,6 +168,5 @@ var useEkho = function useEkho(_ref) {
|
|
|
194
168
|
}, [getVoice, playSpeech, isMounted, voice, text, audioType, audio === null || audio === void 0 ? void 0 : audio.url, audio, setCurrentPlaying, onError, started]);
|
|
195
169
|
return stopCurrentAudio;
|
|
196
170
|
};
|
|
197
|
-
|
|
198
171
|
var _default = useEkho;
|
|
199
172
|
exports.default = _default;
|
package/dist/helpers/useGLB.js
CHANGED
|
@@ -4,20 +4,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _reactPromiseSuspense = _interopRequireDefault(require("react-promise-suspense"));
|
|
9
|
-
|
|
10
8
|
var _GLTFLoader = require("three/examples/jsm/loaders/GLTFLoader");
|
|
11
|
-
|
|
12
9
|
var _DRACOLoader = require("three/examples/jsm/loaders/DRACOLoader");
|
|
13
|
-
|
|
14
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
|
|
16
11
|
// We need this to reuse GLTF and DRACO loaders for Arcade working
|
|
17
12
|
// in Mobile devices, drei.useGLTF instances new loaders every time is
|
|
18
13
|
// used
|
|
14
|
+
|
|
19
15
|
// const dracoDecoderPath = 'https://www.gstatic.com/draco/v1/decoders/';
|
|
20
|
-
var dracoDecoderPath = 'https://www.gstatic.com/draco/versioned/decoders/1.4.2/';
|
|
16
|
+
var dracoDecoderPath = 'https://www.gstatic.com/draco/versioned/decoders/1.4.2/';
|
|
17
|
+
// Changed to specific version because 1.4.3 seems to have issues
|
|
21
18
|
// TODO: Maybe download those files to statics.gamelearn
|
|
22
19
|
|
|
23
20
|
var whiteImage = new Image();
|
|
@@ -26,14 +23,12 @@ var dracoLoader = new _DRACOLoader.DRACOLoader();
|
|
|
26
23
|
var gltfLoader = new _GLTFLoader.GLTFLoader();
|
|
27
24
|
dracoLoader.setDecoderPath(dracoDecoderPath);
|
|
28
25
|
gltfLoader.setDRACOLoader(dracoLoader);
|
|
29
|
-
|
|
30
26
|
var treatGeometry = function treatGeometry(res) {
|
|
31
27
|
res.scene.traverse(function (obj) {
|
|
32
28
|
if (obj.isMesh || obj.isSkinnedMesh) {
|
|
33
29
|
var keys = Object.keys(obj.material);
|
|
34
30
|
keys.forEach(function (key) {
|
|
35
31
|
var value = obj.material[key];
|
|
36
|
-
|
|
37
32
|
if (value && value.isTexture) {
|
|
38
33
|
obj.material[key].image = whiteImage;
|
|
39
34
|
}
|
|
@@ -42,24 +37,21 @@ var treatGeometry = function treatGeometry(res) {
|
|
|
42
37
|
}
|
|
43
38
|
});
|
|
44
39
|
};
|
|
45
|
-
|
|
46
40
|
var fetchGlb = function fetchGlb(originalUrl) {
|
|
47
41
|
var isTexturableObject = originalUrl.includes('/character/') || originalUrl.includes('/object/') || originalUrl.includes('/gl_asset/');
|
|
48
42
|
var url = isTexturableObject ? originalUrl.replace('.glb', '.geometry.glb') : originalUrl;
|
|
49
43
|
return new Promise(function (resolve, reject) {
|
|
50
44
|
gltfLoader.load(url, function (result) {
|
|
51
|
-
treatGeometry(result);
|
|
52
|
-
|
|
45
|
+
treatGeometry(result);
|
|
46
|
+
// result.scene.userData.url = originalUrl;
|
|
53
47
|
resolve(result);
|
|
54
48
|
}, null, function (error) {
|
|
55
49
|
return reject(error);
|
|
56
50
|
});
|
|
57
51
|
});
|
|
58
52
|
};
|
|
59
|
-
|
|
60
53
|
var useGLB = function useGLB(url) {
|
|
61
54
|
return (0, _reactPromiseSuspense.default)(fetchGlb, [url]);
|
|
62
55
|
};
|
|
63
|
-
|
|
64
56
|
var _default = useGLB;
|
|
65
57
|
exports.default = _default;
|