@sage-rsc/talking-head-react 1.0.28 → 1.0.29

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/index.cjs CHANGED
@@ -1 +1 @@
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;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./index-C3A1_CcE.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
@@ -1,4 +1,4 @@
1
- import { C as n, T as s, a as t, d as e, b as o, g, c as m, h as r } from "./index-zMY6cyU2.js";
1
+ import { C as n, T as s, a as t, d as e, b as o, g, c as m, h as r } from "./index-BvDk1TRw.js";
2
2
  export {
3
3
  n as CurriculumLearning,
4
4
  s as TalkingHeadAvatar,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sage-rsc/talking-head-react",
3
- "version": "1.0.28",
3
+ "version": "1.0.29",
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",
@@ -199,6 +199,9 @@ const CurriculumLearning = forwardRef(({
199
199
  }
200
200
  }
201
201
  }, [animations.lessonComplete, curriculum, completeCurriculum, defaultAvatarConfig]);
202
+
203
+ // Assign ref immediately after function is defined
204
+ completeLessonRef.current = completeLesson;
202
205
 
203
206
  // Complete entire curriculum
204
207
  const completeCurriculum = useCallback(() => {
@@ -323,9 +326,12 @@ const CurriculumLearning = forwardRef(({
323
326
  }
324
327
  }
325
328
  } else {
326
- completeLesson();
329
+ // Use ref to avoid circular dependency
330
+ if (completeLessonRef.current) {
331
+ completeLessonRef.current();
332
+ }
327
333
  }
328
- }, [animations.nextQuestion, getCurrentLesson, completeLesson, getCurrentQuestion, defaultAvatarConfig]);
334
+ }, [animations.nextQuestion, getCurrentLesson, getCurrentQuestion, defaultAvatarConfig]);
329
335
 
330
336
  // Move to next lesson
331
337
  const nextLesson = useCallback(() => {
@@ -361,6 +367,9 @@ const CurriculumLearning = forwardRef(({
361
367
  completeCurriculum();
362
368
  }
363
369
  }, [curriculum, completeCurriculum]);
370
+
371
+ // Assign ref immediately after function is defined
372
+ nextLessonRef.current = nextLesson;
364
373
 
365
374
  // Start teaching the lesson
366
375
  const startTeaching = useCallback(() => {
@@ -416,6 +425,9 @@ const CurriculumLearning = forwardRef(({
416
425
  }, 8000);
417
426
  }
418
427
  }, [animations.teaching, getCurrentLesson, startQuestions, defaultAvatarConfig]);
428
+
429
+ // Assign ref immediately after function is defined
430
+ startTeachingRef.current = startTeaching;
419
431
 
420
432
  // Handle answer selection
421
433
  const handleAnswerSelect = useCallback((answer) => {
@@ -546,23 +558,18 @@ const CurriculumLearning = forwardRef(({
546
558
  stateRef.current.totalQuestions = 0;
547
559
  }, []);
548
560
 
549
- // Handle avatar ready callback
561
+ // Handle avatar ready callback - use ref to avoid circular dependency
550
562
  const handleAvatarReady = useCallback((talkingHead) => {
551
563
  console.log('Avatar is ready!', talkingHead);
552
564
  const currentLesson = getCurrentLesson();
553
565
  if (autoStart && currentLesson?.avatar_script) {
554
566
  setTimeout(() => {
555
- startTeaching();
567
+ if (startTeachingRef.current) {
568
+ startTeachingRef.current();
569
+ }
556
570
  }, 1000);
557
571
  }
558
- }, [autoStart, getCurrentLesson, startTeaching]);
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]);
572
+ }, [autoStart, getCurrentLesson]);
566
573
 
567
574
  // Expose methods via ref (for external control)
568
575
  useImperativeHandle(ref, () => ({