@sage-rsc/talking-head-react 1.0.27 → 1.0.28
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/{fbxAnimationLoader-BoEg8dON.cjs → fbxAnimationLoader-BAdAJQ7P.cjs} +1 -1
- package/dist/{fbxAnimationLoader-BndnRQYi.js → fbxAnimationLoader-xd44uqKF.js} +1 -1
- package/dist/index-Dx7mDKJm.cjs +13 -0
- package/dist/{index-DPiBXfzj.js → index-zMY6cyU2.js} +1377 -1375
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/src/components/CurriculumLearning.jsx +39 -12
- package/dist/index-COqTUp83.cjs +0 -13
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./index-Dx7mDKJm.cjs");exports.CurriculumLearning=i.CurriculumLearning;exports.TalkingHeadAvatar=i.TalkingHeadAvatar;exports.TalkingHeadComponent=i.TalkingHeadComponent;exports.animations=i.animations;exports.getActiveTTSConfig=i.getActiveTTSConfig;exports.getAnimation=i.getAnimation;exports.getVoiceOptions=i.getVoiceOptions;exports.hasAnimation=i.hasAnimation;
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -51,6 +51,11 @@ const CurriculumLearning = forwardRef(({
|
|
|
51
51
|
onCustomAction
|
|
52
52
|
});
|
|
53
53
|
|
|
54
|
+
// Refs for functions to avoid circular dependencies
|
|
55
|
+
const startTeachingRef = useRef(null);
|
|
56
|
+
const nextLessonRef = useRef(null);
|
|
57
|
+
const completeLessonRef = useRef(null);
|
|
58
|
+
|
|
54
59
|
// Update callbacks ref when they change
|
|
55
60
|
useEffect(() => {
|
|
56
61
|
callbacksRef.current = {
|
|
@@ -111,13 +116,20 @@ const CurriculumLearning = forwardRef(({
|
|
|
111
116
|
return false;
|
|
112
117
|
}, []);
|
|
113
118
|
|
|
114
|
-
// Complete current lesson
|
|
119
|
+
// Complete current lesson - defined before it's used to avoid circular dependency
|
|
115
120
|
const completeLesson = useCallback(() => {
|
|
116
121
|
stateRef.current.lessonCompleted = true;
|
|
117
122
|
stateRef.current.isQuestionMode = false;
|
|
118
123
|
|
|
119
|
-
const percentage =
|
|
120
|
-
|
|
124
|
+
const percentage = stateRef.current.totalQuestions > 0
|
|
125
|
+
? Math.round((stateRef.current.score / stateRef.current.totalQuestions) * 100)
|
|
126
|
+
: 100;
|
|
127
|
+
let feedbackMessage = `Congratulations! You've completed this lesson`;
|
|
128
|
+
if (stateRef.current.totalQuestions > 0) {
|
|
129
|
+
feedbackMessage += ` with a score of ${stateRef.current.score} out of ${stateRef.current.totalQuestions} (${percentage}%). `;
|
|
130
|
+
} else {
|
|
131
|
+
feedbackMessage += `! `;
|
|
132
|
+
}
|
|
121
133
|
|
|
122
134
|
if (percentage >= 80) {
|
|
123
135
|
feedbackMessage += "Excellent work! You have a great understanding of this topic.";
|
|
@@ -150,7 +162,7 @@ const CurriculumLearning = forwardRef(({
|
|
|
150
162
|
if (animations.lessonComplete) {
|
|
151
163
|
try {
|
|
152
164
|
avatarRef.current.playAnimation(animations.lessonComplete, true);
|
|
153
|
-
|
|
165
|
+
} catch (error) {
|
|
154
166
|
avatarRef.current.playCelebration();
|
|
155
167
|
}
|
|
156
168
|
}
|
|
@@ -165,12 +177,15 @@ const CurriculumLearning = forwardRef(({
|
|
|
165
177
|
lipsyncLang: defaultAvatarConfig.lipsyncLang,
|
|
166
178
|
onSpeechEnd: () => {
|
|
167
179
|
// Add a small delay after speech ends for natural flow
|
|
168
|
-
|
|
169
|
-
|
|
180
|
+
setTimeout(() => {
|
|
181
|
+
// Use ref to avoid circular dependency
|
|
182
|
+
if (nextLessonRef.current) {
|
|
183
|
+
nextLessonRef.current();
|
|
184
|
+
}
|
|
170
185
|
}, 1000);
|
|
171
186
|
}
|
|
172
187
|
});
|
|
173
|
-
|
|
188
|
+
} else {
|
|
174
189
|
// This is the last lesson, complete curriculum instead
|
|
175
190
|
avatarRef.current.speakText(feedbackMessage, {
|
|
176
191
|
lipsyncLang: defaultAvatarConfig.lipsyncLang,
|
|
@@ -183,7 +198,7 @@ const CurriculumLearning = forwardRef(({
|
|
|
183
198
|
});
|
|
184
199
|
}
|
|
185
200
|
}
|
|
186
|
-
}, [animations.lessonComplete, curriculum,
|
|
201
|
+
}, [animations.lessonComplete, curriculum, completeCurriculum, defaultAvatarConfig]);
|
|
187
202
|
|
|
188
203
|
// Complete entire curriculum
|
|
189
204
|
const completeCurriculum = useCallback(() => {
|
|
@@ -337,13 +352,15 @@ const CurriculumLearning = forwardRef(({
|
|
|
337
352
|
|
|
338
353
|
// Automatically start teaching the next lesson after a brief pause
|
|
339
354
|
setTimeout(() => {
|
|
340
|
-
|
|
355
|
+
if (startTeachingRef.current) {
|
|
356
|
+
startTeachingRef.current();
|
|
357
|
+
}
|
|
341
358
|
}, 500);
|
|
342
359
|
}
|
|
343
360
|
} else {
|
|
344
361
|
completeCurriculum();
|
|
345
362
|
}
|
|
346
|
-
}, [curriculum, completeCurriculum
|
|
363
|
+
}, [curriculum, completeCurriculum]);
|
|
347
364
|
|
|
348
365
|
// Start teaching the lesson
|
|
349
366
|
const startTeaching = useCallback(() => {
|
|
@@ -391,11 +408,14 @@ const CurriculumLearning = forwardRef(({
|
|
|
391
408
|
if (currentLesson.questions && currentLesson.questions.length > 0) {
|
|
392
409
|
startQuestions();
|
|
393
410
|
} else {
|
|
394
|
-
|
|
411
|
+
// No questions, complete the lesson using ref to avoid circular dependency
|
|
412
|
+
if (completeLessonRef.current) {
|
|
413
|
+
completeLessonRef.current();
|
|
414
|
+
}
|
|
395
415
|
}
|
|
396
416
|
}, 8000);
|
|
397
417
|
}
|
|
398
|
-
}, [animations.teaching, getCurrentLesson, startQuestions,
|
|
418
|
+
}, [animations.teaching, getCurrentLesson, startQuestions, defaultAvatarConfig]);
|
|
399
419
|
|
|
400
420
|
// Handle answer selection
|
|
401
421
|
const handleAnswerSelect = useCallback((answer) => {
|
|
@@ -537,6 +557,13 @@ const CurriculumLearning = forwardRef(({
|
|
|
537
557
|
}
|
|
538
558
|
}, [autoStart, getCurrentLesson, startTeaching]);
|
|
539
559
|
|
|
560
|
+
// Update refs after all functions are defined to avoid circular dependency issues
|
|
561
|
+
useEffect(() => {
|
|
562
|
+
startTeachingRef.current = startTeaching;
|
|
563
|
+
nextLessonRef.current = nextLesson;
|
|
564
|
+
completeLessonRef.current = completeLesson;
|
|
565
|
+
}, [startTeaching, nextLesson, completeLesson]);
|
|
566
|
+
|
|
540
567
|
// Expose methods via ref (for external control)
|
|
541
568
|
useImperativeHandle(ref, () => ({
|
|
542
569
|
// Curriculum control methods
|