@spatialwalk/avatarkit 1.0.0-beta.2 → 1.0.0-beta.21

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.
Files changed (67) hide show
  1. package/CHANGELOG.md +340 -0
  2. package/README.md +501 -194
  3. package/dist/StreamingAudioPlayer-DEXcuhRW.js +334 -0
  4. package/dist/StreamingAudioPlayer-DEXcuhRW.js.map +1 -0
  5. package/dist/animation/AnimationWebSocketClient.d.ts +7 -4
  6. package/dist/animation/AnimationWebSocketClient.d.ts.map +1 -1
  7. package/dist/audio/AnimationPlayer.d.ts +12 -0
  8. package/dist/audio/AnimationPlayer.d.ts.map +1 -1
  9. package/dist/audio/StreamingAudioPlayer.d.ts +11 -0
  10. package/dist/audio/StreamingAudioPlayer.d.ts.map +1 -1
  11. package/dist/avatar_core_wasm-BPIbbUx_.js +1664 -0
  12. package/dist/avatar_core_wasm-BPIbbUx_.js.map +1 -0
  13. package/dist/avatar_core_wasm.wasm +0 -0
  14. package/dist/config/app-config.d.ts +3 -7
  15. package/dist/config/app-config.d.ts.map +1 -1
  16. package/dist/config/constants.d.ts +19 -3
  17. package/dist/config/constants.d.ts.map +1 -1
  18. package/dist/config/sdk-config-loader.d.ts.map +1 -1
  19. package/dist/core/Avatar.d.ts +0 -8
  20. package/dist/core/Avatar.d.ts.map +1 -1
  21. package/dist/core/AvatarController.d.ts +112 -65
  22. package/dist/core/AvatarController.d.ts.map +1 -1
  23. package/dist/core/AvatarDownloader.d.ts +1 -20
  24. package/dist/core/AvatarDownloader.d.ts.map +1 -1
  25. package/dist/core/AvatarKit.d.ts +8 -15
  26. package/dist/core/AvatarKit.d.ts.map +1 -1
  27. package/dist/core/AvatarManager.d.ts +1 -4
  28. package/dist/core/AvatarManager.d.ts.map +1 -1
  29. package/dist/core/AvatarView.d.ts +65 -53
  30. package/dist/core/AvatarView.d.ts.map +1 -1
  31. package/dist/core/NetworkLayer.d.ts +8 -0
  32. package/dist/core/NetworkLayer.d.ts.map +1 -0
  33. package/dist/index-ChKhyUK4.js +6437 -0
  34. package/dist/index-ChKhyUK4.js.map +1 -0
  35. package/dist/index.d.ts +0 -1
  36. package/dist/index.d.ts.map +1 -1
  37. package/dist/index.js +14 -15
  38. package/dist/renderer/RenderSystem.d.ts +9 -76
  39. package/dist/renderer/RenderSystem.d.ts.map +1 -1
  40. package/dist/renderer/webgl/reorderData.d.ts.map +1 -1
  41. package/dist/renderer/webgl/webglRenderer.d.ts.map +1 -1
  42. package/dist/types/character.d.ts +0 -11
  43. package/dist/types/character.d.ts.map +1 -1
  44. package/dist/types/index.d.ts +18 -6
  45. package/dist/types/index.d.ts.map +1 -1
  46. package/dist/utils/cls-tracker.d.ts +17 -0
  47. package/dist/utils/cls-tracker.d.ts.map +1 -0
  48. package/dist/utils/{reqId.d.ts → conversationId.d.ts} +6 -6
  49. package/dist/utils/conversationId.d.ts.map +1 -0
  50. package/dist/utils/logger.d.ts +2 -10
  51. package/dist/utils/logger.d.ts.map +1 -1
  52. package/dist/vanilla/vite.config.d.ts +3 -0
  53. package/dist/vanilla/vite.config.d.ts.map +1 -0
  54. package/dist/wasm/avatarCoreAdapter.d.ts +58 -9
  55. package/dist/wasm/avatarCoreAdapter.d.ts.map +1 -1
  56. package/dist/wasm/avatarCoreMemory.d.ts +5 -1
  57. package/dist/wasm/avatarCoreMemory.d.ts.map +1 -1
  58. package/package.json +10 -4
  59. package/dist/StreamingAudioPlayer-CMEiGwxE.js +0 -288
  60. package/dist/StreamingAudioPlayer-CMEiGwxE.js.map +0 -1
  61. package/dist/avatar_core_wasm-DmkU6dYn.js +0 -1666
  62. package/dist/avatar_core_wasm-DmkU6dYn.js.map +0 -1
  63. package/dist/index-CNhquYUE.js +0 -9712
  64. package/dist/index-CNhquYUE.js.map +0 -1
  65. package/dist/utils/posthog-tracker.d.ts +0 -82
  66. package/dist/utils/posthog-tracker.d.ts.map +0 -1
  67. package/dist/utils/reqId.d.ts.map +0 -1
package/CHANGELOG.md ADDED
@@ -0,0 +1,340 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [1.0.0-beta.21] - 2025-01-25
9
+
10
+ ### ✨ New Features
11
+ - **SDK Mode Connection Timeout Fallback** - Enhanced fallback mechanism for SDK mode:
12
+ - If WebSocket connection fails to establish within 15 seconds, the SDK automatically enters fallback mode
13
+ - In fallback mode, audio data can still be sent and will play normally, even though no animation data will be received
14
+ - Connection failures also trigger this fallback mechanism
15
+ - `ConnectionState.connecting` and `ConnectionState.failed` events are emitted to notify external applications
16
+ - Concurrent connection attempts are prevented to avoid race conditions
17
+
18
+ ### 🔧 Improvements
19
+ - Improved connection state management: `isConnected` now accurately reflects actual connection status (false in fallback mode)
20
+ - Added `canSend()` method in `NetworkLayer` to check if audio can be sent (including fallback mode)
21
+ - Better separation of concerns: connection state checks are now handled by `NetworkLayer`, while playback logic remains in `AvatarController`
22
+
23
+ ## [1.0.0-beta.20] - 2025-01-25
24
+
25
+ ### 🔧 Improvements
26
+ - Removed 1-second audio buffer requirement for auto-starting playback in Host mode
27
+
28
+ ## [1.0.0-beta.19] - 2025-01-25
29
+
30
+ ### 📚 Documentation
31
+ - **Fixed misleading documentation** - Corrected Host mode API documentation to accurately reflect that `yieldAudioData()` can be called directly to start a new session without requiring `playback()` first
32
+ - Removed misleading "after playback() is called" comments
33
+ - Clarified two ways to start a session: using `playback()` for existing data, or `yieldAudioData()` directly for streaming
34
+ - Updated all examples and workflow descriptions to reflect correct API usage
35
+
36
+ ## [1.0.0-beta.18] - 2025-01-25
37
+
38
+ ### 🔧 API Changes
39
+ - **Renamed `reqId` to `conversationId`** - Updated terminology for better clarity
40
+ - All methods and parameters that used `reqId` now use `conversationId`
41
+ - `getCurrentReqId()` → `getCurrentConversationId()`
42
+ - `generateReqId()` → `generateConversationId()`
43
+ - Updated all event logs and documentation to use `conversationId`
44
+ - Note: Protobuf protocol still uses `reqId` field name internally, but SDK API uses `conversationId`
45
+
46
+ ### 📚 Documentation
47
+ - Enhanced Host mode documentation to clearly emphasize the workflow: send audio data first to get conversationId, then use that conversationId to send animation data
48
+ - Updated Host Mode Example and Host Mode Flow sections with clearer step-by-step instructions
49
+
50
+ ## [1.0.0-beta.17] - 2025-01-24
51
+
52
+ ### ✨ New Features
53
+ - **Audio-Only Fallback Mechanism** - SDK now includes automatic fallback to audio-only playback when animation data is unavailable
54
+ - SDK mode: Automatically enters audio-only mode when server returns an error
55
+ - Host mode: Automatically enters audio-only mode when empty animation data is provided
56
+ - Once in audio-only mode, subsequent animation data for that session is ignored
57
+ - Fallback mode is interruptible, just like normal playback mode
58
+
59
+ ### 🔧 API Changes
60
+ - **Playback Mode Configuration** - Moved playback mode configuration from `AvatarView` constructor to `AvatarKit.initialize()`
61
+ - Playback mode is now determined by `drivingServiceMode` in `AvatarKit.initialize()` configuration
62
+ - `AvatarView` constructor now only requires `avatar` and `container` parameters
63
+ - Removed `AvatarViewOptions` interface
64
+ - `container` parameter is now required (no longer optional)
65
+ - **Method Renames** - Renamed methods in `AvatarController` for Host mode to better reflect their purpose
66
+ - `play()` → `playback()`: Renamed to better reflect that the method is used for playback of existing data (replay mode)
67
+ - Old API: `avatarController.play(initialAudioChunks, initialKeyframes)`
68
+ - New API: `avatarController.playback(initialAudioChunks, initialKeyframes)`
69
+ - `sendAudioChunk()` → `yieldAudioData()`: Renamed to better reflect that the method yields/streams audio data
70
+ - Old API: `avatarController.sendAudioChunk(data, isLast)`
71
+ - New API: `avatarController.yieldAudioData(data, isLast)`
72
+ - `sendKeyframes()` → `yieldFramesData()`: Renamed to better reflect that the method yields/streams animation keyframes
73
+ - Old API: `avatarController.sendKeyframes(keyframes, reqId)`
74
+ - New API: `avatarController.yieldFramesData(keyframes, conversationId)`
75
+
76
+ ### 🔧 Improvements
77
+ - Extended transition animation duration from 200ms to 400ms for smoother end-of-playback transitions
78
+
79
+ ### 📚 Documentation
80
+ - Updated README.md to use "SDK mode" and "Host mode" terminology instead of "Network mode" and "External data mode"
81
+ - Added fallback mechanism documentation
82
+ - Updated API reference to reflect new constructor signature
83
+
84
+ ## [1.0.0-beta.16] - 2025-11-21
85
+
86
+ ### ✨ New Features
87
+ - **Multi-AvatarView Support** - SDK now supports multiple `AvatarView` instances simultaneously
88
+ - Each `AvatarView` instance can manage its own character independently
89
+ - Multiple characters can be displayed and controlled at the same time
90
+ - Each instance maintains its own rendering context, playback state, and network connection
91
+ - Removed the previous limitation of "only one AvatarView instance at a time"
92
+
93
+ ### 📚 Documentation
94
+ - Updated README.md to reflect multi-character support capabilities
95
+ - Added multi-character usage examples
96
+ - Removed outdated limitation notes about single AvatarView instance
97
+
98
+ ---
99
+
100
+ ## [1.0.0-beta.15] - 2025-01-20
101
+
102
+ ### ✨ New Features
103
+ - Added authentication support for API requests
104
+ - `appId` is now automatically included in HTTP headers (`X-App-Id`) and WebSocket URL query parameters
105
+ - `sessionToken` is now automatically included in HTTP headers (`Authorization: Bearer {token}`) and WebSocket URL query parameters
106
+ - All network requests (character loading, resource downloads, WebSocket connections) now include authentication credentials
107
+
108
+ ### 🔧 Improvements
109
+ - Fixed canvas resize handling for different aspect ratios
110
+ - Projection matrix is now correctly updated when canvas aspect ratio changes
111
+ - Rendering system properly handles portrait (9:16) and landscape (16:9) aspect ratios
112
+ - Canvas automatically adapts to container size changes via ResizeObserver
113
+
114
+ ### 🐛 Bug Fixes
115
+ - Fixed `RenderSystem.handleResize()` to update projection matrix when canvas size changes
116
+ - Previously only updated aspect ratio, now also updates projection matrix for correct rendering
117
+
118
+ ---
119
+
120
+ ## [1.0.0-beta.14] - 2025-11-18
121
+
122
+ ### ✨ New Features
123
+ - Added pause and resume functionality for avatar playback
124
+ - New `pause()` method to pause audio and animation playback
125
+ - New `resume()` method to resume playback from paused state
126
+ - Added `paused` state to `AvatarState` enum
127
+ - State changes are communicated via `onAvatarState` callback
128
+ - Works in both network mode and external data mode
129
+
130
+ ### 🔧 Improvements
131
+ - Canvas now uses container's full dimensions instead of fixed 1:1 aspect ratio
132
+ - Canvas automatically adapts to container size (width and height)
133
+ - External developers can control canvas aspect ratio by setting container dimensions
134
+ - Rendering system correctly handles any aspect ratio without distortion
135
+
136
+ ---
137
+
138
+ ## [1.0.0-beta.13] - 2025-11-17
139
+
140
+ ### 🔒 API Improvements
141
+ - Reduced console noise by setting default log level to Warning
142
+ - Logger now only outputs warnings and errors by default
143
+ - Set `VITE_DEBUG_LOG=true` to enable all logs
144
+ - Simplified logger configuration using `setGlobalLogLevel(LogLevel.Warning)`
145
+
146
+ ### 🐛 Bug Fixes
147
+ - Fixed SDK config loader warning in non-debug mode
148
+ - Config loading failures are now silently handled in production
149
+ - Warnings only shown when `VITE_DEBUG_LOG=true`
150
+
151
+ ---
152
+
153
+ ## [1.0.0-beta.12] - 2025-11-17
154
+
155
+ ### 🔒 API Improvements
156
+ - Marked performance monitoring APIs as internal
157
+ - `RenderPerformanceStats` interface and `getPerformanceStats()` method are now marked with `@internal` tag
158
+ - These APIs are not exposed in the public TypeScript definitions
159
+ - Reverted performance monitoring implementation to simpler version (only `renderTime` and `sortTime`)
160
+
161
+ ---
162
+
163
+ ## [1.0.0-beta.11] - 2025-11-17
164
+
165
+ ### 📚 Documentation
166
+ - Updated demo repository link in README.md
167
+ - Changed example project link from `Avatarkit-web-demo` to `AvatarKit-Web-Demo` to match the new repository name
168
+
169
+ ---
170
+
171
+ ## [1.0.0-beta.10] - 2025-11-16
172
+
173
+ ### 🔒 API Improvements
174
+ - Cleaned up public API to hide internal implementation details
175
+ - Marked internal methods with `@internal` JSDoc tag to exclude them from TypeScript declarations
176
+ - Removed unused environment configuration options (`realtimeApiBaseUrl`, `realtimeWsUrl`)
177
+ - Added `appId` getter to `AvatarKit` for accessing initialized app ID
178
+ - Internal methods like `getEnvironmentConfig`, `logEvent`, `getCanvas`, `getCameraConfig`, `updateCameraConfig` are now properly hidden from public API
179
+
180
+ ### 🐛 Bug Fixes
181
+ - Fixed memory leaks when disposing AvatarView instances
182
+ - Improved resource cleanup to prevent memory leaks when switching or disposing avatar instances
183
+ - Properly clears all callbacks, event listeners, and large data buffers on disposal
184
+
185
+ ---
186
+ ## [1.0.0-beta.9] - 2025-11-15
187
+
188
+ ### 🐛 Bug Fixes
189
+ - Fixed memory leaks when disposing AvatarView instances
190
+ - Improved resource cleanup to prevent memory leaks when switching or disposing avatar instances
191
+ - Properly clears all callbacks, event listeners, and large data buffers on disposal
192
+
193
+ ---
194
+
195
+ ## [1.0.0-beta.8] - 2025-11-14
196
+
197
+ ### 🐛 Bug Fixes
198
+ - Fixed audio-animation synchronization issue after normal playback completion
199
+ - Playback state is now properly cleaned up when audio finishes normally, preventing synchronization issues in subsequent conversations
200
+
201
+ ---
202
+
203
+ ## [1.0.0-beta.7] - 2025-11-14
204
+
205
+ ### 🔄 Refactoring
206
+ - Improved rendering state management for better stability and maintainability
207
+
208
+ ### 🐛 Bug Fixes
209
+ - Fixed interrupt not generating transition animation when interrupting during playback
210
+ - Fixed transition animation being regenerated and reset in external data mode when sending keyframes after playback starts
211
+
212
+ ---
213
+
214
+ ## [1.0.0-beta.6] - 2025-11-14
215
+
216
+ ### 🐛 Bug Fixes
217
+ - Fixed transition animation being regenerated and reset in external data mode when sending keyframes after playback starts, causing the transition to play twice
218
+
219
+ ---
220
+
221
+ ## [1.0.0-beta.5] - 2025-11-14
222
+
223
+ ### 🐛 Bug Fixes
224
+ - Fixed missing `AvatarPlaybackMode` enum export in published package
225
+
226
+ ---
227
+
228
+ ## [1.0.0-beta.4] - 2025-11-14
229
+
230
+ ### 🔄 Updates
231
+ - Updated WASM module (avatar_core_wasm.wasm)
232
+
233
+ ---
234
+
235
+ ## [1.0.0-beta.3] - 2025-11-13
236
+
237
+ ### 🎉 Major Changes
238
+
239
+ #### Architecture Refactoring - Three-Layer Architecture
240
+ - **Rendering Layer (AvatarView)**: Pure rendering responsibility, receives rendering instructions from the playback layer
241
+ - **Playback Layer (AvatarController)**: Unified data controller responsible for audio playback and animation rendering synchronization
242
+ - **Network Layer (NetworkLayer)**: Optional network communication layer, automatically composed only in network mode
243
+
244
+ #### Dual Playback Mode Support
245
+ - **Network Mode**:
246
+ - Send audio data to server via WebSocket
247
+ - Automatically receive and play animation data returned from server
248
+ - Use `controller.start()` and `controller.send()` methods
249
+
250
+ - **External Data Mode**:
251
+ - External components fully control audio and animation data acquisition
252
+ - SDK only responsible for synchronized playback of externally provided data
253
+ - Use `controller.playback()`, `controller.yieldAudioData()` and `controller.yieldFramesData()` methods
254
+
255
+ ### ✨ New Features
256
+
257
+ - **Transition Animation Optimization**:
258
+ - Transition animation duration adjusted to 200ms
259
+ - Improved audio-animation synchronization logic, ensuring audio and animation start playing together after transition animation ends
260
+ - Optimized transition frame generation and alignment logic
261
+
262
+ - **Camera Configuration Enhancement**:
263
+ - Default transparent background, background rendering functionality removed
264
+ - Camera configuration aligned with iOS (Reversed-Z projection, near=0.01, far=100)
265
+ - Support dynamic camera configuration loading from characterSettings and camera.json
266
+
267
+ - **Audio Sample Rate Configuration**:
268
+ - Updated default audio sample rate to 16kHz (previously 24kHz) to match backend requirements
269
+ - Audio format requirement: 16kHz mono PCM16
270
+
271
+ - **Telemetry Migration**:
272
+ - Migrated from PostHog to Tencent Cloud CLS (Cloud Log Service)
273
+ - Support environment-based dynamic configuration (cn/test/us)
274
+ - Support both Token and SecretId/SecretKey authentication methods
275
+ - Aligned with iOS SDK configuration
276
+
277
+ ### 🔧 API Changes
278
+
279
+ #### Breaking Changes
280
+
281
+ - **AvatarView Constructor**:
282
+ ```typescript
283
+ // Old API
284
+ new AvatarView(avatar, container)
285
+
286
+ // New API
287
+ new AvatarView(avatar, {
288
+ container: container,
289
+ playbackMode: AvatarPlaybackMode.network // or AvatarPlaybackMode.external
290
+ })
291
+ ```
292
+
293
+ - **AvatarController Methods**:
294
+ - Network Mode: `start()` / `close()` / `send()`
295
+ - External Data Mode: `play()` / `sendAudioChunk()` / `sendKeyframes()`
296
+ - Common Methods: `interrupt()` / `clear()` / `dispose()`
297
+
298
+ - **Removed Properties**:
299
+ - `realtimeStartTime` property removed (no longer needed)
300
+
301
+ ### 🐛 Bug Fixes
302
+
303
+ - Fixed audio-animation desynchronization during transition animation
304
+ - Fixed animation freezing issue in external data mode
305
+ - Fixed audio playback speed abnormality caused by sample rate mismatch
306
+ - Fixed camera configuration priority logic
307
+ - Fixed WebSocket connection state callback timing issues
308
+
309
+ ### 📚 Documentation
310
+
311
+ - Updated README.md with detailed explanation of three-layer architecture and two playback modes
312
+ - Added audio format requirements documentation (16kHz mono PCM16)
313
+ - Updated API reference documentation and code examples
314
+ - Added architecture diagrams and flowcharts
315
+
316
+ ### 🧪 Testing
317
+
318
+ - Updated unit tests to cover new architecture
319
+ - Added unit tests for external data mode
320
+ - Updated E2E tests to use new API
321
+ - All tests passing (69 unit tests + 24 E2E tests)
322
+
323
+ ### 🔄 Internal Changes
324
+
325
+ - Refactored `AvatarController` into unified playback layer
326
+ - Extracted `NetworkLayer` as independent component
327
+ - Optimized animation playback loop and audio-animation synchronization logic
328
+ - Updated WASM module (avatar_core_wasm.wasm)
329
+ - Improved error handling and logging
330
+
331
+ ### 📦 Dependencies
332
+
333
+ - No new dependencies added
334
+ - Maintained existing dependency versions
335
+
336
+ ---
337
+
338
+ ## [1.0.0-beta.2] - Previous Version
339
+
340
+ (Previous version changelog entries...)