@spatialwalk/avatarkit 1.0.0-beta.71 → 1.0.0-beta.72
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/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.0.0-beta.72] - 2026-01-17
|
|
9
|
+
|
|
10
|
+
### 📚 Documentation
|
|
11
|
+
- **README Optimization** - Enhanced README with authentication section and improved API documentation
|
|
12
|
+
|
|
8
13
|
## [1.0.0-beta.71] - 2026-01-17
|
|
9
14
|
|
|
10
15
|
### 🔧 Improvements
|
package/README.md
CHANGED
|
@@ -18,13 +18,34 @@ Real-time virtual avatar rendering SDK based on 3D Gaussian Splatting, supportin
|
|
|
18
18
|
npm install @spatialwalk/avatarkit
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
##
|
|
21
|
+
## 🚀 Demo Repository
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
<div align="center">
|
|
24
24
|
|
|
25
|
-
###
|
|
25
|
+
### 📌 **Quick Start: Check Out Our Demo Repository**
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
We provide complete example code and best practices to help you quickly integrate the SDK.
|
|
28
|
+
|
|
29
|
+
**The demo repository includes:**
|
|
30
|
+
- ✅ Complete integration examples
|
|
31
|
+
- ✅ Usage examples for both SDK mode and Host mode
|
|
32
|
+
- ✅ Audio processing examples (PCM16, WAV, MP3, etc.)
|
|
33
|
+
- ✅ Vite configuration examples
|
|
34
|
+
- ✅ Best practices for common scenarios
|
|
35
|
+
|
|
36
|
+
**[👉 View Demo Repository](https://github.com/spatialwalk/avatarkit-demo)** | *If not yet created, please contact the team*
|
|
37
|
+
|
|
38
|
+
</div>
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## 🔧 Vite Configuration (Recommended)
|
|
43
|
+
|
|
44
|
+
If you are using Vite as your build tool, we strongly recommend using our Vite plugin to automatically handle WASM file configuration. The plugin automatically handles all necessary configurations, so you don't need to set them up manually.
|
|
45
|
+
|
|
46
|
+
### Using the Plugin
|
|
47
|
+
|
|
48
|
+
Add the plugin to `vite.config.ts`:
|
|
28
49
|
|
|
29
50
|
```typescript
|
|
30
51
|
import { defineConfig } from 'vite'
|
|
@@ -32,27 +53,27 @@ import { avatarkitVitePlugin } from '@spatialwalk/avatarkit/vite'
|
|
|
32
53
|
|
|
33
54
|
export default defineConfig({
|
|
34
55
|
plugins: [
|
|
35
|
-
avatarkitVitePlugin(), //
|
|
56
|
+
avatarkitVitePlugin(), // Just add this line
|
|
36
57
|
],
|
|
37
58
|
})
|
|
38
59
|
```
|
|
39
60
|
|
|
40
|
-
###
|
|
61
|
+
### Plugin Features
|
|
41
62
|
|
|
42
|
-
|
|
63
|
+
The plugin automatically handles:
|
|
43
64
|
|
|
44
|
-
- ✅
|
|
45
|
-
- ✅
|
|
46
|
-
-
|
|
47
|
-
-
|
|
48
|
-
-
|
|
49
|
-
- ✅ **WASM JS Glue
|
|
50
|
-
- ✅ **Cloudflare Pages
|
|
51
|
-
- ✅ **Vite
|
|
65
|
+
- ✅ **Development Server**: Automatically sets the correct MIME type (`application/wasm`) for WASM files
|
|
66
|
+
- ✅ **Build Time**: Automatically copies WASM files to `dist/assets/` directory
|
|
67
|
+
- Smart Detection: Extracts referenced WASM file names (including hash) from JS glue files
|
|
68
|
+
- Auto Matching: Ensures copied WASM files match references in JS glue files
|
|
69
|
+
- Hash Support: Correctly handles hashed WASM files (e.g., `avatar_core_wasm-{hash}.wasm`)
|
|
70
|
+
- ✅ **WASM JS Glue**: Automatically copies WASM JS glue files to `dist/assets/` directory
|
|
71
|
+
- ✅ **Cloudflare Pages**: Automatically generates `_headers` file to ensure WASM files use the correct MIME type
|
|
72
|
+
- ✅ **Vite Configuration**: Automatically configures `optimizeDeps`, `assetsInclude`, `assetsInlineLimit`, and other options
|
|
52
73
|
|
|
53
|
-
###
|
|
74
|
+
### Manual Configuration (Without Plugin)
|
|
54
75
|
|
|
55
|
-
|
|
76
|
+
If you don't use the Vite plugin, you need to manually configure the following:
|
|
56
77
|
|
|
57
78
|
```typescript
|
|
58
79
|
// vite.config.ts
|
|
@@ -74,7 +95,7 @@ export default defineConfig({
|
|
|
74
95
|
},
|
|
75
96
|
},
|
|
76
97
|
},
|
|
77
|
-
//
|
|
98
|
+
// Development server needs to manually configure middleware to set WASM MIME type
|
|
78
99
|
configureServer(server) {
|
|
79
100
|
server.middlewares.use((req, res, next) => {
|
|
80
101
|
if (req.url?.endsWith('.wasm')) {
|
|
@@ -86,6 +107,53 @@ export default defineConfig({
|
|
|
86
107
|
})
|
|
87
108
|
```
|
|
88
109
|
|
|
110
|
+
## 🔐 Authentication
|
|
111
|
+
|
|
112
|
+
All environments require an **App ID** and **Session Token** for authentication.
|
|
113
|
+
|
|
114
|
+
### App ID
|
|
115
|
+
|
|
116
|
+
The App ID is used to identify your application. You can obtain your App ID by:
|
|
117
|
+
|
|
118
|
+
1. **For Testing**: Use the default test App ID provided in demo repositories (paired with test Session Token, only works with publicly available test avatars like Rohan, Dr.Kellan, Priya, Josh, etc.)
|
|
119
|
+
2. **For Production**: Visit the [Developer Platform](https://dash.spatialreal.ai) to create your own App and avatars. You will receive your own App ID after creating an App.
|
|
120
|
+
|
|
121
|
+
### Session Token
|
|
122
|
+
|
|
123
|
+
The Session Token is required for WebSocket authentication and must be obtained from your SDK provider.
|
|
124
|
+
|
|
125
|
+
**⚠️ Important Notes:**
|
|
126
|
+
- The Session Token must be valid and not expired
|
|
127
|
+
- In production applications, you **must** manually inject a valid Session Token obtained from your SDK provider
|
|
128
|
+
- The default Session Token provided in demo repositories is **only for demonstration purposes** and can only be used with test avatars
|
|
129
|
+
- If you want to create your own avatars and test them, please visit the [Developer Platform](https://dash.spatialreal.ai) to create your own App and generate Session Tokens
|
|
130
|
+
|
|
131
|
+
**How to Set Session Token:**
|
|
132
|
+
|
|
133
|
+
```typescript
|
|
134
|
+
// Initialize SDK with App ID
|
|
135
|
+
await AvatarSDK.initialize('your-app-id', configuration)
|
|
136
|
+
|
|
137
|
+
// Set Session Token (can be called before or after initialization)
|
|
138
|
+
// If called before initialization, the token will be automatically set when you initialize the SDK
|
|
139
|
+
AvatarSDK.setSessionToken('your-session-token')
|
|
140
|
+
|
|
141
|
+
// Get current Session Token
|
|
142
|
+
const sessionToken = AvatarSDK.sessionToken
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
**Token Management:**
|
|
146
|
+
- The Session Token can be set at any time using `AvatarSDK.setSessionToken(token)`
|
|
147
|
+
- If you set the token before initializing the SDK, it will be automatically applied during initialization
|
|
148
|
+
- If you set the token after initialization, it will be applied immediately
|
|
149
|
+
- Handle token refresh logic in your application as needed (e.g., when token expires)
|
|
150
|
+
|
|
151
|
+
**For Production Integration:**
|
|
152
|
+
- Obtain a valid Session Token from your SDK provider
|
|
153
|
+
- Store the token securely (never expose it in client-side code if possible)
|
|
154
|
+
- Implement token refresh logic to handle token expiration
|
|
155
|
+
- Use `AvatarSDK.setSessionToken(token)` to inject the token programmatically
|
|
156
|
+
|
|
89
157
|
## 🎯 Quick Start
|
|
90
158
|
|
|
91
159
|
### ⚠️ Important: Audio Context Initialization
|
|
@@ -126,8 +194,10 @@ const configuration: Configuration = {
|
|
|
126
194
|
|
|
127
195
|
await AvatarSDK.initialize('your-app-id', configuration)
|
|
128
196
|
|
|
129
|
-
// Set
|
|
130
|
-
//
|
|
197
|
+
// Set Session Token (required for authentication)
|
|
198
|
+
// You must obtain a valid Session Token from your SDK provider
|
|
199
|
+
// See Authentication section above for more details
|
|
200
|
+
AvatarSDK.setSessionToken('your-session-token')
|
|
131
201
|
|
|
132
202
|
// 2. Load avatar
|
|
133
203
|
const avatarManager = AvatarManager.shared
|
|
@@ -408,7 +478,9 @@ const appId = AvatarSDK.appId
|
|
|
408
478
|
// Get configuration
|
|
409
479
|
const config = AvatarSDK.configuration
|
|
410
480
|
|
|
411
|
-
// Set
|
|
481
|
+
// Set Session Token (required for authentication)
|
|
482
|
+
// You must obtain a valid Session Token from your SDK provider
|
|
483
|
+
// See Authentication section for more details
|
|
412
484
|
AvatarSDK.setSessionToken('your-session-token')
|
|
413
485
|
|
|
414
486
|
// Set userId (optional, for telemetry)
|
|
@@ -437,7 +509,7 @@ const manager = AvatarManager.shared
|
|
|
437
509
|
|
|
438
510
|
// Load avatar
|
|
439
511
|
const avatar = await manager.load(
|
|
440
|
-
|
|
512
|
+
id: string,
|
|
441
513
|
onProgress?: (progress: LoadProgressInfo) => void
|
|
442
514
|
)
|
|
443
515
|
|
|
@@ -505,7 +577,7 @@ const newAvatar = await avatarManager.load('new-character-id')
|
|
|
505
577
|
currentAvatarView = new AvatarView(newAvatar, container)
|
|
506
578
|
|
|
507
579
|
// SDK mode: start connection (will throw error if not in SDK mode)
|
|
508
|
-
|
|
580
|
+
await currentAvatarView.controller.start()
|
|
509
581
|
```
|
|
510
582
|
|
|
511
583
|
### AvatarController
|
|
@@ -581,24 +653,30 @@ button.addEventListener('click', async () => {
|
|
|
581
653
|
|
|
582
654
|
```typescript
|
|
583
655
|
|
|
656
|
+
// Pause playback (from playing state)
|
|
657
|
+
avatarView.controller.pause()
|
|
658
|
+
|
|
659
|
+
// Resume playback (from paused state)
|
|
660
|
+
await avatarView.controller.resume()
|
|
661
|
+
|
|
584
662
|
// Interrupt current playback (stops and clears data)
|
|
585
|
-
avatarView.
|
|
663
|
+
avatarView.controller.interrupt()
|
|
586
664
|
|
|
587
665
|
// Clear all data and resources
|
|
588
|
-
avatarView.
|
|
666
|
+
avatarView.controller.clear()
|
|
589
667
|
|
|
590
668
|
// Get current conversation ID (for Host mode)
|
|
591
|
-
const conversationId = avatarView.
|
|
669
|
+
const conversationId = avatarView.controller.getCurrentConversationId()
|
|
592
670
|
// Returns: Current conversationId for the active audio session, or null if no active session
|
|
593
671
|
|
|
594
672
|
// Volume control (affects only avatar audio player, not system volume)
|
|
595
|
-
avatarView.
|
|
596
|
-
const currentVolume = avatarView.
|
|
673
|
+
avatarView.controller.setVolume(0.5) // Set volume to 50% (0.0 to 1.0)
|
|
674
|
+
const currentVolume = avatarView.controller.getVolume() // Get current volume (0.0 to 1.0)
|
|
597
675
|
|
|
598
676
|
// Set event callbacks
|
|
599
|
-
avatarView.
|
|
600
|
-
avatarView.
|
|
601
|
-
avatarView.
|
|
677
|
+
avatarView.controller.onConnectionState = (state: ConnectionState) => {} // SDK mode only
|
|
678
|
+
avatarView.controller.onConversationState = (state: ConversationState) => {}
|
|
679
|
+
avatarView.controller.onError = (error: Error) => {}
|
|
602
680
|
```
|
|
603
681
|
|
|
604
682
|
#### Avatar Transform Methods
|
|
@@ -674,7 +752,7 @@ enum LogLevel {
|
|
|
674
752
|
- Supported values: 8000, 16000, 22050, 24000, 32000, 44100, 48000
|
|
675
753
|
- The configured sample rate will be used for both audio recording and playback
|
|
676
754
|
- `characterApiBaseUrl`: Internal debug config, can be ignored
|
|
677
|
-
- `sessionToken`: Set separately via `AvatarSDK.setSessionToken()`, not in Configuration
|
|
755
|
+
- `sessionToken`: **Required for authentication**. Set separately via `AvatarSDK.setSessionToken()`, not in Configuration. See [Authentication](#-authentication) section for details
|
|
678
756
|
|
|
679
757
|
```typescript
|
|
680
758
|
enum Environment {
|
|
@@ -734,7 +812,7 @@ enum ConversationState {
|
|
|
734
812
|
The SDK supports two rendering backends:
|
|
735
813
|
|
|
736
814
|
- **WebGPU** - High-performance rendering for modern browsers
|
|
737
|
-
- **WebGL** - Better compatibility traditional rendering
|
|
815
|
+
- **WebGL** - Better compatibility for traditional rendering
|
|
738
816
|
|
|
739
817
|
The rendering system automatically selects the best backend, no manual configuration needed.
|
|
740
818
|
|
|
@@ -748,7 +826,7 @@ The SDK uses custom error types, providing more detailed error information:
|
|
|
748
826
|
import { AvatarError } from '@spatialwalk/avatarkit'
|
|
749
827
|
|
|
750
828
|
try {
|
|
751
|
-
await avatarView.
|
|
829
|
+
await avatarView.controller.start()
|
|
752
830
|
} catch (error) {
|
|
753
831
|
if (error instanceof AvatarError) {
|
|
754
832
|
console.error('SDK Error:', error.message, error.code)
|
|
@@ -761,7 +839,7 @@ try {
|
|
|
761
839
|
### Error Callbacks
|
|
762
840
|
|
|
763
841
|
```typescript
|
|
764
|
-
avatarView.
|
|
842
|
+
avatarView.controller.onError = (error: Error) => {
|
|
765
843
|
console.error('AvatarController error:', error)
|
|
766
844
|
// Handle error, such as reconnection, user notification, etc.
|
|
767
845
|
}
|
|
@@ -777,14 +855,13 @@ avatarView.avatarController.onError = (error: Error) => {
|
|
|
777
855
|
// Initialize
|
|
778
856
|
const container = document.getElementById('avatar-container')
|
|
779
857
|
const avatarView = new AvatarView(avatar, container)
|
|
780
|
-
await avatarView.
|
|
858
|
+
await avatarView.controller.start()
|
|
781
859
|
|
|
782
860
|
// Use
|
|
783
|
-
avatarView.
|
|
861
|
+
avatarView.controller.send(audioData, false)
|
|
784
862
|
|
|
785
|
-
// Cleanup
|
|
786
|
-
avatarView.
|
|
787
|
-
avatarView.dispose() // Automatically cleans up all resources
|
|
863
|
+
// Cleanup - dispose() automatically cleans up all resources including WebSocket connections
|
|
864
|
+
avatarView.dispose()
|
|
788
865
|
```
|
|
789
866
|
|
|
790
867
|
#### Host Mode Lifecycle
|
|
@@ -795,19 +872,21 @@ const container = document.getElementById('avatar-container')
|
|
|
795
872
|
const avatarView = new AvatarView(avatar, container)
|
|
796
873
|
|
|
797
874
|
// Use
|
|
798
|
-
const conversationId = avatarView.
|
|
799
|
-
avatarView.
|
|
875
|
+
const conversationId = avatarView.controller.yieldAudioData(audioChunk, false)
|
|
876
|
+
avatarView.controller.yieldFramesData(keyframesDataArray, conversationId) // keyframesDataArray: (Uint8Array | ArrayBuffer)[]
|
|
800
877
|
|
|
801
|
-
// Cleanup
|
|
802
|
-
avatarView.
|
|
803
|
-
avatarView.dispose() // Automatically cleans up all resources
|
|
878
|
+
// Cleanup - dispose() automatically cleans up all resources including playback data
|
|
879
|
+
avatarView.dispose()
|
|
804
880
|
```
|
|
805
881
|
|
|
806
882
|
**⚠️ Important Notes:**
|
|
807
|
-
-
|
|
808
|
-
-
|
|
809
|
-
-
|
|
810
|
-
-
|
|
883
|
+
- `dispose()` automatically cleans up all resources, including:
|
|
884
|
+
- WebSocket connections (SDK mode)
|
|
885
|
+
- Playback data and animation resources (both modes)
|
|
886
|
+
- Render system and canvas elements
|
|
887
|
+
- All event listeners and callbacks
|
|
888
|
+
- Not properly calling `dispose()` may cause resource leaks and rendering errors
|
|
889
|
+
- If you need to manually close WebSocket connections or clear playback data before disposing, you can call `avatarView.controller.close()` (SDK mode) or `avatarView.controller.clear()` (both modes) first, but it's not required as `dispose()` handles this automatically
|
|
811
890
|
|
|
812
891
|
### Memory Optimization
|
|
813
892
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
-
import { A as APP_CONFIG, l as logger, e as errorToMessage, a as logEvent } from "./index-
|
|
4
|
+
import { A as APP_CONFIG, l as logger, e as errorToMessage, a as logEvent } from "./index-BginsqFH.js";
|
|
5
5
|
class StreamingAudioPlayer {
|
|
6
6
|
// Mark if AudioContext is being resumed, avoid concurrent resume requests
|
|
7
7
|
constructor(options) {
|
|
@@ -7860,7 +7860,7 @@ const _AnimationPlayer = class _AnimationPlayer {
|
|
|
7860
7860
|
if (this.streamingPlayer) {
|
|
7861
7861
|
return;
|
|
7862
7862
|
}
|
|
7863
|
-
const { StreamingAudioPlayer } = await import("./StreamingAudioPlayer-
|
|
7863
|
+
const { StreamingAudioPlayer } = await import("./StreamingAudioPlayer-fV-zTOrl.js");
|
|
7864
7864
|
const { AvatarSDK: AvatarSDK2 } = await Promise.resolve().then(() => AvatarSDK$1);
|
|
7865
7865
|
const audioFormat = AvatarSDK2.getAudioFormat();
|
|
7866
7866
|
this.streamingPlayer = new StreamingAudioPlayer({
|
|
@@ -9531,7 +9531,7 @@ class AvatarSDK {
|
|
|
9531
9531
|
}
|
|
9532
9532
|
__publicField(AvatarSDK, "_isInitialized", false);
|
|
9533
9533
|
__publicField(AvatarSDK, "_configuration", null);
|
|
9534
|
-
__publicField(AvatarSDK, "_version", "1.0.0-beta.
|
|
9534
|
+
__publicField(AvatarSDK, "_version", "1.0.0-beta.72");
|
|
9535
9535
|
__publicField(AvatarSDK, "_avatarCore", null);
|
|
9536
9536
|
__publicField(AvatarSDK, "_dynamicSdkConfig", null);
|
|
9537
9537
|
const AvatarSDK$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
package/dist/index.js
CHANGED
package/package.json
CHANGED