@sage-rsc/talking-head-react 1.3.8 → 1.4.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sage-rsc/talking-head-react",
3
- "version": "1.3.8",
3
+ "version": "1.4.1",
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",
@@ -0,0 +1,108 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Merge script to update TalkingHead while preserving customizations
4
+ *
5
+ * This script:
6
+ * 1. Takes upstream talkinghead.mjs as base
7
+ * 2. Extracts custom methods from current version
8
+ * 3. Inserts them into the right places in upstream version
9
+ */
10
+
11
+ import fs from 'fs';
12
+ import path from 'path';
13
+
14
+ const UPSTREAM_FILE = '/tmp/upstream-talkinghead.mjs';
15
+ const CURRENT_FILE = 'src/lib/talkinghead.mjs';
16
+ const OUTPUT_FILE = 'src/lib/talkinghead.mjs.merged';
17
+
18
+ // Custom methods to extract and preserve
19
+ const CUSTOM_METHODS = [
20
+ 'lockAvatarPosition',
21
+ 'unlockAvatarPosition',
22
+ 'maintainLockedPosition',
23
+ 'applyShoulderAdjustment',
24
+ 'applyShoulderAdjustmentToBones',
25
+ 'initializeFBXAnimationLoader',
26
+ 'setBodyMovement',
27
+ 'applyBodyMovementAnimation',
28
+ 'createBodyMovementAnimation'
29
+ ];
30
+
31
+ // Custom code sections to preserve
32
+ const CUSTOM_SECTIONS = [
33
+ // Imports
34
+ { start: /import \{ AudioAnalyzer \}/, end: /^import/ },
35
+ { start: /\/\/ Import lipsync modules statically/, end: /^const LIPSYNC_MODULES/ },
36
+ { start: /^const LIPSYNC_MODULES/, end: /^\};/ },
37
+
38
+ // Position locking calls in methods
39
+ { start: /this\.lockAvatarPosition\(\)/, end: null },
40
+ { start: /this\.unlockAvatarPosition\(\)/, end: null },
41
+ { start: /this\.maintainLockedPosition\(\)/, end: null },
42
+ { start: /this\.positionWasLocked/, end: null },
43
+
44
+ // Shoulder adjustment calls
45
+ { start: /this\.applyShoulderAdjustment\(\)/, end: null },
46
+ { start: /this\.applyShoulderAdjustmentToBones\(\)/, end: null },
47
+
48
+ // FBX loader calls
49
+ { start: /this\.fbxAnimationLoader/, end: null },
50
+ ];
51
+
52
+ console.log('Reading files...');
53
+ const upstream = fs.readFileSync(UPSTREAM_FILE, 'utf8');
54
+ const current = fs.readFileSync(CURRENT_FILE, 'utf8');
55
+
56
+ console.log(`Upstream: ${upstream.split('\\n').length} lines`);
57
+ console.log(`Current: ${current.split('\\n').length} lines`);
58
+
59
+ // Extract custom methods from current file
60
+ const customMethods = {};
61
+ const lines = current.split('\\n');
62
+
63
+ CUSTOM_METHODS.forEach(methodName => {
64
+ const methodRegex = new RegExp(`^ ${methodName}\\(`);
65
+ const startIdx = lines.findIndex(line => methodRegex.test(line));
66
+
67
+ if (startIdx !== -1) {
68
+ // Find the end of the method (next method or closing brace at same indent level)
69
+ let braceCount = 0;
70
+ let inMethod = false;
71
+ let endIdx = startIdx;
72
+
73
+ for (let i = startIdx; i < lines.length; i++) {
74
+ const line = lines[i];
75
+ if (line.match(/^ [a-zA-Z].*\(/)) {
76
+ if (inMethod && braceCount === 0) {
77
+ endIdx = i;
78
+ break;
79
+ }
80
+ if (line.match(methodRegex)) {
81
+ inMethod = true;
82
+ }
83
+ }
84
+ braceCount += (line.match(/{/g) || []).length;
85
+ braceCount -= (line.match(/}/g) || []).length;
86
+
87
+ if (inMethod && braceCount === 0 && i > startIdx) {
88
+ endIdx = i + 1;
89
+ break;
90
+ }
91
+ }
92
+
93
+ customMethods[methodName] = lines.slice(startIdx, endIdx).join('\\n');
94
+ console.log(`Extracted ${methodName}: ${endIdx - startIdx} lines`);
95
+ }
96
+ });
97
+
98
+ console.log('\\nExtracted custom methods:', Object.keys(customMethods));
99
+
100
+ // For now, just report what was found
101
+ console.log('\\n=== Merge Strategy ===');
102
+ console.log('1. Start with upstream file');
103
+ console.log('2. Add custom imports at top');
104
+ console.log('3. Insert custom methods before dispose()');
105
+ console.log('4. Add custom method calls in appropriate places');
106
+ console.log('\\nManual merge required due to complexity.');
107
+ console.log('See CUSTOMIZATIONS.md for detailed list of what to preserve.');
108
+
@@ -0,0 +1,51 @@
1
+ #!/bin/bash
2
+ # Script to help update TalkingHead while preserving customizations
3
+
4
+ set -e
5
+
6
+ echo "=== TalkingHead Update Helper ==="
7
+ echo ""
8
+ echo "This script helps identify customizations to preserve during update."
9
+ echo ""
10
+
11
+ # Colors for output
12
+ GREEN='\033[0;32m'
13
+ YELLOW='\033[1;33m'
14
+ NC='\033[0m' # No Color
15
+
16
+ echo -e "${GREEN}Step 1: Identifying custom methods...${NC}"
17
+ echo ""
18
+ echo "=== Position Locking Methods ==="
19
+ grep -n "lockAvatarPosition\|unlockAvatarPosition\|maintainLockedPosition" src/lib/talkinghead.mjs | head -20
20
+
21
+ echo ""
22
+ echo "=== Shoulder Adjustment Methods ==="
23
+ grep -n "applyShoulderAdjustment" src/lib/talkinghead.mjs | head -10
24
+
25
+ echo ""
26
+ echo "=== Position Locking Calls ==="
27
+ grep -n "lockAvatarPosition\|unlockAvatarPosition\|positionWasLocked\|lockedPosition" src/lib/talkinghead.mjs | head -20
28
+
29
+ echo ""
30
+ echo -e "${YELLOW}Step 2: Custom files to preserve (DO NOT REPLACE):${NC}"
31
+ echo "- src/components/TalkingHeadComponent.jsx"
32
+ echo "- src/components/TalkingHeadAvatar.jsx"
33
+ echo "- src/components/SimpleTalkingAvatar.jsx"
34
+ echo "- src/components/CurriculumLearning.jsx"
35
+ echo "- src/config/ttsConfig.js"
36
+ echo "- src/lib/enhancedFBXLoader.js"
37
+ echo "- src/lib/fbxAnimationLoader.js"
38
+ echo "- src/utils/animationLoader.js"
39
+ echo "- scripts/generate-animation-manifest.js"
40
+
41
+ echo ""
42
+ echo -e "${GREEN}Step 3: Next steps:${NC}"
43
+ echo "1. Download latest TalkingHead source"
44
+ echo "2. Compare talkinghead.mjs files"
45
+ echo "3. Merge changes while preserving custom methods above"
46
+ echo "4. Test thoroughly"
47
+ echo ""
48
+ echo "To compare files, use:"
49
+ echo " diff -u old-talkinghead.mjs src/lib/talkinghead.mjs > talkinghead.diff"
50
+ echo ""
51
+