@sage-rsc/talking-head-react 1.0.67 → 1.0.69

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sage-rsc/talking-head-react",
3
- "version": "1.0.67",
3
+ "version": "1.0.69",
4
4
  "description": "A reusable React component for 3D talking avatars with lip-sync and text-to-speech",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
@@ -23,6 +23,12 @@ import TalkingHeadAvatar from './TalkingHeadAvatar';
23
23
  * @param {Function} props.onCurriculumComplete - Callback when curriculum completes
24
24
  * @param {Function} props.onCustomAction - Callback for custom actions (receives action type and data)
25
25
  * - 'teachingComplete': Fired when teaching finishes. Check data.hasQuestions to know if questions are available.
26
+ * - 'codeExampleReady': Fired after teaching if lesson has a code_example. Contains codeExample object with:
27
+ * - code: The code string to type/run in IDE
28
+ * - language: Programming language (default: 'javascript')
29
+ * - description: Optional description of what the code does
30
+ * - autoRun: Whether to auto-run after typing (default: false)
31
+ * - typingSpeed: Typing speed in ms per character (default: 50)
26
32
  * - 'answerFeedbackComplete': Fired when answer feedback finishes. Check data.hasNextQuestion to know if more questions exist.
27
33
  * - 'lessonCompleteFeedbackDone': Fired when lesson completion feedback finishes. Check data.hasNextLesson to know if more lessons exist.
28
34
  * - 'allQuestionsComplete': Fired when all questions in a lesson are done. Parent should call completeLesson() when ready.
@@ -632,6 +638,18 @@ const CurriculumLearning = forwardRef(({
632
638
  lesson: currentLesson,
633
639
  hasQuestions: currentLesson.questions && currentLesson.questions.length > 0
634
640
  });
641
+
642
+ // Check if there's a code example to demonstrate
643
+ if (currentLesson?.code_example) {
644
+ // Trigger code example event - parent can handle IDE typing/running
645
+ callbacksRef.current.onCustomAction({
646
+ type: 'codeExampleReady',
647
+ moduleIndex: stateRef.current.currentModuleIndex,
648
+ lessonIndex: stateRef.current.currentLessonIndex,
649
+ lesson: currentLesson,
650
+ codeExample: currentLesson.code_example
651
+ });
652
+ }
635
653
  }
636
654
  });
637
655
  }
@@ -671,6 +689,10 @@ const CurriculumLearning = forwardRef(({
671
689
  const currentLesson = getCurrentLesson();
672
690
  const totalQuestionsInLesson = currentLesson?.questions?.length || 0;
673
691
  const isLastQuestion = stateRef.current.currentQuestionIndex >= totalQuestionsInLesson - 1;
692
+ const hasNextQuestion = stateRef.current.currentQuestionIndex < totalQuestionsInLesson - 1;
693
+
694
+ // Debug logging
695
+ console.log('[CurriculumLearning] Answer feedback - questionIndex:', stateRef.current.currentQuestionIndex, 'totalQuestions:', totalQuestionsInLesson, 'hasNextQuestion:', hasNextQuestion);
674
696
 
675
697
  const successMessage = currentQuestion.type === "code_test"
676
698
  ? `Great job! Your code passed all the tests! ${currentQuestion.explanation || ''}`
@@ -689,7 +711,7 @@ const CurriculumLearning = forwardRef(({
689
711
  lessonIndex: stateRef.current.currentLessonIndex,
690
712
  questionIndex: stateRef.current.currentQuestionIndex,
691
713
  isCorrect: true,
692
- hasNextQuestion: stateRef.current.currentQuestionIndex < totalQuestionsInLesson - 1,
714
+ hasNextQuestion: hasNextQuestion,
693
715
  score: stateRef.current.score,
694
716
  totalQuestions: stateRef.current.totalQuestions
695
717
  });
@@ -710,6 +732,10 @@ const CurriculumLearning = forwardRef(({
710
732
  const currentLesson = getCurrentLesson();
711
733
  const totalQuestionsInLesson = currentLesson?.questions?.length || 0;
712
734
  const isLastQuestion = stateRef.current.currentQuestionIndex >= totalQuestionsInLesson - 1;
735
+ const hasNextQuestion = stateRef.current.currentQuestionIndex < totalQuestionsInLesson - 1;
736
+
737
+ // Debug logging
738
+ console.log('[CurriculumLearning] Answer feedback (incorrect) - questionIndex:', stateRef.current.currentQuestionIndex, 'totalQuestions:', totalQuestionsInLesson, 'hasNextQuestion:', hasNextQuestion);
713
739
 
714
740
  const failureMessage = currentQuestion.type === "code_test"
715
741
  ? `Your code didn't pass all the tests. ${currentQuestion.explanation || 'Try again!'}`
@@ -728,7 +754,7 @@ const CurriculumLearning = forwardRef(({
728
754
  lessonIndex: stateRef.current.currentLessonIndex,
729
755
  questionIndex: stateRef.current.currentQuestionIndex,
730
756
  isCorrect: false,
731
- hasNextQuestion: stateRef.current.currentQuestionIndex < totalQuestionsInLesson - 1,
757
+ hasNextQuestion: hasNextQuestion,
732
758
  score: stateRef.current.score,
733
759
  totalQuestions: stateRef.current.totalQuestions
734
760
  });