@spatialwalk/avatarkit 1.0.0-beta.67 → 1.0.0-beta.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.
Files changed (49) hide show
  1. package/CHANGELOG.md +33 -11
  2. package/README.md +102 -18
  3. package/dist/{StreamingAudioPlayer-CD9jBs6B.js → StreamingAudioPlayer-DiIRp5nx.js} +109 -1
  4. package/dist/animation/AnimationWebSocketClient.d.ts +26 -0
  5. package/dist/animation/utils/eventEmitter.d.ts +3 -0
  6. package/dist/animation/utils/flameConverter.d.ts +10 -3
  7. package/dist/audio/AnimationPlayer.d.ts +46 -0
  8. package/dist/audio/StreamingAudioPlayer.d.ts +93 -0
  9. package/dist/config/app-config.d.ts +5 -1
  10. package/dist/config/constants.d.ts +7 -1
  11. package/dist/config/sdk-config-loader.d.ts +11 -3
  12. package/dist/core/Avatar.d.ts +10 -0
  13. package/dist/core/AvatarController.d.ts +164 -2
  14. package/dist/core/AvatarDownloader.d.ts +10 -0
  15. package/dist/core/AvatarManager.d.ts +27 -1
  16. package/dist/core/AvatarSDK.d.ts +27 -0
  17. package/dist/core/AvatarView.d.ts +148 -3
  18. package/dist/core/NetworkLayer.d.ts +6 -0
  19. package/dist/generated/common/v1/models.d.ts +8 -1
  20. package/dist/generated/driveningress/v1/driveningress.d.ts +11 -1
  21. package/dist/generated/driveningress/v2/driveningress.d.ts +5 -2
  22. package/dist/generated/google/protobuf/struct.d.ts +38 -5
  23. package/dist/generated/google/protobuf/timestamp.d.ts +102 -1
  24. package/dist/{index-GRm00rtd.js → index-BT9yxWW8.js} +1468 -30
  25. package/dist/index.d.ts +3 -0
  26. package/dist/index.js +1 -1
  27. package/dist/renderer/RenderSystem.d.ts +8 -0
  28. package/dist/renderer/covariance.d.ts +11 -0
  29. package/dist/renderer/sortSplats.d.ts +10 -0
  30. package/dist/renderer/webgl/reorderData.d.ts +12 -0
  31. package/dist/renderer/webgl/webglRenderer.d.ts +53 -0
  32. package/dist/renderer/webgpu/webgpuRenderer.d.ts +38 -0
  33. package/dist/types/character-settings.d.ts +4 -0
  34. package/dist/types/character.d.ts +9 -3
  35. package/dist/types/index.d.ts +56 -23
  36. package/dist/utils/animation-interpolation.d.ts +30 -5
  37. package/dist/utils/client-id.d.ts +5 -0
  38. package/dist/utils/conversationId.d.ts +18 -0
  39. package/dist/utils/error-utils.d.ts +24 -1
  40. package/dist/utils/id-manager.d.ts +26 -0
  41. package/dist/utils/logger.d.ts +4 -1
  42. package/dist/utils/posthog-tracker.d.ts +27 -5
  43. package/dist/utils/pwa-cache-manager.d.ts +36 -0
  44. package/dist/utils/usage-tracker.d.ts +17 -2
  45. package/dist/vite.d.ts +16 -1
  46. package/dist/wasm/avatarCoreAdapter.d.ts +145 -0
  47. package/dist/wasm/avatarCoreMemory.d.ts +52 -0
  48. package/package.json +3 -3
  49. package/vite.js +45 -29
@@ -10,9 +10,16 @@ export interface FlameParams {
10
10
  eyelid?: number[];
11
11
  has_eyelid?: boolean;
12
12
  }
13
-
13
+ /**
14
+ * Convert proto Flame to WASM FlameParams format
15
+ */
14
16
  export declare function convertProtoFlameToWasmParams(protoFlame: Flame): FlameParams;
15
-
17
+ /**
18
+ * Convert WASM FlameParams to proto Flame format
19
+ * Used for transition animation from idle to speaking
20
+ */
16
21
  export declare function convertWasmParamsToProtoFlame(wasmParams: FlameParams): Flame;
17
-
22
+ /**
23
+ * Create a neutral proto Flame (zero pose)
24
+ */
18
25
  export declare function createNeutralFlameProto(): Flame;
@@ -7,23 +7,69 @@ export declare class AnimationPlayer {
7
7
  private onEndedCallback?;
8
8
  private static audioUnlocked;
9
9
  private useStreaming;
10
+ /**
11
+ * 解锁音频上下文(Safari 自动播放策略)
12
+ * 必须在用户交互事件(如 click)中调用
13
+ */
10
14
  static unlockAudioContext(): Promise<void>;
15
+ /**
16
+ * Initialize with HTMLAudioElement (traditional way)
17
+ */
11
18
  initialize(audioUrl: string, onEnded?: () => void): Promise<void>;
19
+ /**
20
+ * Initialize with StreamingAudioPlayer (streaming way)
21
+ * @deprecated 使用 prepareStreamingPlayer() 代替
22
+ */
12
23
  initializeStreaming(streamingPlayer: StreamingAudioPlayer, onEnded?: () => void): Promise<void>;
24
+ /**
25
+ * 检查流式播放器是否已准备好
26
+ */
13
27
  isStreamingReady(): boolean;
28
+ /**
29
+ * 获取流式播放器实例
30
+ */
14
31
  getStreamingPlayer(): StreamingAudioPlayer | null;
32
+ /**
33
+ * 创建并初始化流式播放器
34
+ * 在服务连接建立时调用
35
+ */
15
36
  createAndInitializeStreamingPlayer(): Promise<void>;
37
+ /**
38
+ * 准备流式播放器(如果未创建则创建并初始化)
39
+ * 停止之前的播放并更新结束回调
40
+ */
16
41
  prepareStreamingPlayer(onEnded?: () => void): Promise<void>;
17
42
  private setupEventListeners;
18
43
  play(): Promise<void>;
19
44
  stop(): void;
20
45
  isPlaying(): boolean;
21
46
  getCurrentFrameIndex(): number;
47
+ /**
48
+ * Get current playback time
49
+ */
22
50
  getCurrentTime(): number;
51
+ /**
52
+ * 添加音频块(仅用于流式播放)
53
+ */
23
54
  addAudioChunk(audio: Uint8Array, isLast?: boolean): void;
55
+ /**
56
+ * 暂停播放
57
+ */
24
58
  pause(): void;
59
+ /**
60
+ * 继续播放
61
+ */
25
62
  resume(): Promise<void>;
63
+ /**
64
+ * 设置音量 (0.0 - 1.0)
65
+ * 注意:这仅控制数字人音频播放器的音量,不影响系统音量
66
+ * @param volume 音量值,范围 0.0 到 1.0(0.0 为静音,1.0 为最大音量)
67
+ */
26
68
  setVolume(volume: number): void;
69
+ /**
70
+ * 获取当前音量
71
+ * @returns 当前音量值 (0.0 - 1.0)
72
+ */
27
73
  getVolume(): number;
28
74
  dispose(): void;
29
75
  }
@@ -1,3 +1,8 @@
1
+ /**
2
+ * Streaming Audio Player
3
+ * Implements real-time audio playback using Web Audio API
4
+ * Supports dynamic PCM chunk addition without Workers
5
+ */
1
6
  export interface StreamingAudioPlayerOptions {
2
7
  sampleRate?: number;
3
8
  channelCount?: number;
@@ -30,33 +35,121 @@ export declare class StreamingAudioPlayer {
30
35
  private stateChangeHandler?;
31
36
  private isResuming;
32
37
  constructor(options?: StreamingAudioPlayerOptions);
38
+ /**
39
+ * Initialize audio context (create and ensure it's ready)
40
+ */
33
41
  initialize(): Promise<void>;
42
+ /**
43
+ * 确保 AudioContext 正在运行(如果被暂停则自动恢复)
44
+ * 只在正在播放且未暂停时自动恢复,避免干扰正常的暂停/恢复逻辑
45
+ *
46
+ * 优化:
47
+ * - 快速路径:如果已经是 running 状态,直接返回
48
+ * - 避免并发恢复:使用 isResuming 标志防止重复恢复请求
49
+ * - 处理 closed 状态:如果 AudioContext 已关闭,无法恢复
50
+ */
34
51
  private ensureAudioContextRunning;
52
+ /**
53
+ * Add audio chunk (16-bit PCM)
54
+ */
35
55
  addChunk(pcmData: Uint8Array, isLast?: boolean): void;
56
+ /**
57
+ * Start new session (stop current and start fresh)
58
+ */
36
59
  startNewSession(audioChunks: Array<{
37
60
  data: Uint8Array;
38
61
  isLast: boolean;
39
62
  }>): Promise<void>;
63
+ /**
64
+ * Start playback
65
+ */
40
66
  private startPlayback;
67
+ /**
68
+ * Schedule all pending chunks
69
+ */
41
70
  private scheduleAllChunks;
71
+ /**
72
+ * Schedule next audio chunk
73
+ */
42
74
  private scheduleNextChunk;
75
+ /**
76
+ * Convert PCM data to AudioBuffer
77
+ * Input: 16-bit PCM (int16), Output: AudioBuffer (float32 [-1, 1])
78
+ */
43
79
  private pcmToAudioBuffer;
80
+ /**
81
+ * Get current playback time (seconds)
82
+ * 返回实际播放的音频总时长
83
+ */
44
84
  getCurrentTime(): number;
85
+ /**
86
+ * Get total duration of buffered audio (seconds)
87
+ * 计算所有已缓冲 chunk 的总时长
88
+ */
45
89
  getBufferedDuration(): number;
90
+ /**
91
+ * Get current AudioContext time
92
+ * @returns Current AudioContext time in seconds, or 0 if AudioContext is not initialized
93
+ */
46
94
  getAudioContextTime(): number;
95
+ /**
96
+ * Pause playback
97
+ */
47
98
  pause(): void;
99
+ /**
100
+ * Resume playback
101
+ */
48
102
  resume(): Promise<void>;
103
+ /**
104
+ * Stop playback
105
+ */
49
106
  stop(): void;
107
+ /**
108
+ * Enable or disable auto-start (for delayed start scenarios)
109
+ */
50
110
  setAutoStart(enabled: boolean): void;
111
+ /**
112
+ * Start playback manually (for delayed start scenarios)
113
+ * This allows starting playback after transition animation completes
114
+ */
51
115
  play(): void;
116
+ /**
117
+ * Mark playback as ended
118
+ */
52
119
  markEnded(): void;
120
+ /**
121
+ * Set ended callback
122
+ */
53
123
  onEnded(callback: () => void): void;
124
+ /**
125
+ * Check if playing
126
+ */
54
127
  isPlayingNow(): boolean;
128
+ /**
129
+ * Dispose and cleanup
130
+ */
55
131
  dispose(): void;
132
+ /**
133
+ * Flush buffered audio
134
+ * - hard: stops all playing sources and clears all chunks
135
+ * - soft (default): clears UNSCHEDULED chunks only
136
+ */
56
137
  flush(options?: {
57
138
  hard?: boolean;
58
139
  }): void;
140
+ /**
141
+ * 设置音量 (0.0 - 1.0)
142
+ * 注意:这仅控制数字人音频播放器的音量,不影响系统音量
143
+ * @param volume 音量值,范围 0.0 到 1.0(0.0 为静音,1.0 为最大音量)
144
+ */
59
145
  setVolume(volume: number): void;
146
+ /**
147
+ * 获取当前音量
148
+ * @returns 当前音量值 (0.0 - 1.0)
149
+ */
60
150
  getVolume(): number;
151
+ /**
152
+ * Debug logging
153
+ */
61
154
  private log;
62
155
  }
@@ -2,7 +2,11 @@ export declare const APP_CONFIG: {
2
2
  testEnv: boolean;
3
3
  readonly debug: boolean;
4
4
  rendering: {
5
-
5
+ /**
6
+ * 排序模式
7
+ * - 'balance': 性能优先,首帧排序后复用(默认)
8
+ * - 'quality': 质量优先,每帧重新排序
9
+ */
6
10
  sortMode: "balance" | "quality";
7
11
  };
8
12
  camera: {
@@ -11,5 +11,11 @@ export declare function getPostHogConfig(_environment: Environment): {
11
11
  disableCompression: boolean;
12
12
  };
13
13
  export declare const ENV_TEST: boolean;
14
-
14
+ /**
15
+ * Comprehensive debug mode check
16
+ * Returns true if:
17
+ * - VITE_ENV_TEST is 'true', OR
18
+ * - Running in DEV mode, OR
19
+ * - URL has debug=1 parameter
20
+ */
15
21
  export declare function isDebugMode(): boolean;
@@ -1,7 +1,15 @@
1
1
  import { Environment } from '../types';
2
-
2
+ /**
3
+ * 默认 SDK 配置(当远程配置接口失败时使用)
4
+ */
3
5
  export declare const DEFAULT_SDK_CONFIG: Partial<Record<Environment, string>>;
4
-
6
+ /**
7
+ * 从远程配置接口获取 SDK 配置
8
+ * @param version SDK 版本号
9
+ * @returns 解析后的配置映射
10
+ */
5
11
  export declare function fetchSdkConfig(version: string): Promise<Partial<Record<Environment, string>>>;
6
-
12
+ /**
13
+ * 清除配置缓存(用于测试或重新加载)
14
+ */
7
15
  export declare function clearSdkConfigCache(): void;
@@ -4,6 +4,16 @@ export declare class Avatar {
4
4
  readonly id: string;
5
5
  private characterMeta;
6
6
  private resources;
7
+ /**
8
+ * 构造函数(内部使用)
9
+ * @param id 数字人 ID
10
+ * @param characterMeta 角色元数据
11
+ * @param resources 资源数据
12
+ */
7
13
  constructor(id: string, characterMeta: CharacterMeta, resources: PreloadResult);
14
+ /**
15
+ * Get character metadata
16
+ * @returns Character metadata, including all configuration information (version, resource URLs, camera config, etc.)
17
+ */
8
18
  getCharacterMeta(): CharacterMeta;
9
19
  }
@@ -1,7 +1,7 @@
1
1
  import { Flame } from '../generated/driveningress/v1/driveningress';
2
2
  import { Avatar } from './Avatar';
3
3
  import { AnimationPlayer } from '../audio/AnimationPlayer';
4
- import { AvatarState, ConnectionState, DrivingServiceMode, ConversationState, PostProcessingConfig } from '../types';
4
+ import { AvatarState, ConnectionState, DrivingServiceMode, ConversationState, PostProcessingConfig, KeyframeData } from '../types';
5
5
  export declare class AvatarController {
6
6
  private networkLayer?;
7
7
  private readonly playbackMode;
@@ -43,40 +43,202 @@ export declare class AvatarController {
43
43
  constructor(avatar: Avatar, options?: {
44
44
  playbackMode?: DrivingServiceMode;
45
45
  });
46
+ /**
47
+ * Get current conversation ID
48
+ * Returns the current conversation ID for the active audio session
49
+ * @returns Current conversation ID, or null if no active session
50
+ */
46
51
  getCurrentConversationId(): string | null;
52
+ /**
53
+ * Initialize audio context (must be called in user gesture context)
54
+ *
55
+ * This method must be called before any audio operations (send, yieldAudioData, etc.)
56
+ * to ensure AudioContext is created and initialized in a user gesture context.
57
+ *
58
+ * @example
59
+ * // In user click handler
60
+ * button.addEventListener('click', async () => {
61
+ * await avatarView.controller.initializeAudioContext()
62
+ * // Now you can safely use send() or yieldAudioData()
63
+ * })
64
+ */
47
65
  initializeAudioContext(): Promise<void>;
66
+ /**
67
+ * Check if audio context is initialized
68
+ * @throws AvatarError if audio context is not initialized
69
+ */
48
70
  private checkAudioContextInitialized;
71
+ /**
72
+ * Start service (SDK mode only)
73
+ */
49
74
  start(): Promise<void>;
75
+ /**
76
+ * Send audio to server (SDK mode only)
77
+ * Also cache to data layer for playback
78
+ * @returns conversationId - Conversation ID for this audio session
79
+ */
50
80
  send(audioData: ArrayBuffer, end?: boolean): string | null;
81
+ /**
82
+ * Close service (SDK mode only)
83
+ */
51
84
  close(): void;
85
+ /**
86
+ * Send audio data (host mode)
87
+ * Stream additional audio data after playback()
88
+ * @returns conversationId - Conversation ID for this audio session
89
+ */
52
90
  yieldAudioData(data: Uint8Array, isLast?: boolean): string | null;
91
+ /**
92
+ * Send animation keyframes (host mode or SDK mode)
93
+ * Stream additional animation data after playback()
94
+ *
95
+ * Public API: accepts binary data array (protobuf encoded Message array)
96
+ * @param keyframesDataArray - Animation keyframes binary data array (each element is a protobuf encoded Message) or empty array to trigger audio-only mode
97
+ * @param conversationId - Conversation ID (required). If conversationId doesn't match current conversationId, keyframes will be discarded.
98
+ * Use getCurrentConversationId() to get the current conversationId.
99
+ */
53
100
  yieldFramesData(keyframesDataArray: (Uint8Array | ArrayBuffer)[], conversationId: string): void;
54
- yieldKeyframes(keyframes: Flame[], conversationId: string): void;
101
+ /**
102
+ * Send animation keyframes (host mode)
103
+ * Stream animation keyframes data after yieldAudioData()
104
+ *
105
+ * ⚠️ **Not recommended**: Prefer using `yieldFramesData()` method, which accepts binary data (protobuf encoded Message) with better performance.
106
+ * This method is only for scenarios where you already have decoded KeyframeData arrays.
107
+ *
108
+ * Public API: accepts decoded keyframes
109
+ * @param keyframes - Animation keyframes array (KeyframeData[]) or empty array to trigger audio-only mode
110
+ * @param conversationId - Conversation ID (required). If conversationId doesn't match current conversationId, keyframes will be discarded.
111
+ * Use getCurrentConversationId() to get the current conversationId.
112
+ */
113
+ yieldKeyframes(keyframes: KeyframeData[], conversationId: string): void;
114
+ /**
115
+ * Pause playback (can be resumed later)
116
+ * Pause audio playback and stop render loop, but preserve all state (keyframes, audio buffers, etc.)
117
+ */
55
118
  pause(): void;
119
+ /**
120
+ * Resume playback (from paused state)
121
+ * Resume audio playback and restart render loop
122
+ * Animation will continue from paused frame (because animation time base comes from audio, will auto-sync)
123
+ */
56
124
  resume(): Promise<void>;
125
+ /**
126
+ * Interrupt current playback
127
+ */
57
128
  interrupt(): void;
129
+ /**
130
+ * Clear all data and resources
131
+ */
58
132
  clear(): void;
133
+ /**
134
+ * Generate new conversation ID and log conversation started event
135
+ * @private
136
+ */
59
137
  private generateAndLogNewConversationId;
138
+ /**
139
+ * Clear playback data (keyframes, audio chunks, and playback state)
140
+ * @private
141
+ */
60
142
  private clearPlaybackData;
143
+ /**
144
+ * Reset conversation ID state (for both network and external modes)
145
+ * @private
146
+ */
61
147
  private resetConversationIdState;
148
+ /**
149
+ * Get effective conversation ID (handles both SDK and host modes)
150
+ * @private
151
+ */
62
152
  private getEffectiveConversationId;
153
+ /**
154
+ * Get point cloud count of the current avatar
155
+ * @returns Point cloud count, or null if avatar is not loaded
156
+ */
63
157
  getPointCount(): number | null;
158
+ /**
159
+ * Set post-processing configuration
160
+ * These parameters will be applied in real-time to animation parameters returned by the server
161
+ * @param config Post-processing configuration, or null to clear
162
+ */
64
163
  setPostProcessingConfig(config: PostProcessingConfig | null): void;
164
+ /**
165
+ * 设置完整的 eye tracking 配置到 C++
166
+ * @private
167
+ */
65
168
  private setEyeTrackingConfig;
169
+ /**
170
+ * 重新渲染当前帧(用于暂停状态下更新后处理参数)
171
+ * @private
172
+ */
66
173
  private rerenderCurrentFrame;
174
+ /**
175
+ * Set audio playback volume
176
+ * Note: This only controls the avatar audio player volume, not the system volume
177
+ * @param volume Volume value, range from 0.0 to 1.0 (0.0 = mute, 1.0 = max volume)
178
+ */
67
179
  setVolume(volume: number): void;
180
+ /**
181
+ * Get current audio playback volume
182
+ * @returns Current volume value (0.0 - 1.0)
183
+ */
68
184
  getVolume(): number;
185
+ /**
186
+ * Start streaming playback (internal implementation)
187
+ */
69
188
  private startStreamingPlaybackInternal;
70
189
  private startPlaybackLoop;
190
+ /**
191
+ * Stop playback loop
192
+ */
71
193
  private stopPlaybackLoop;
194
+ /**
195
+ * 启用音频独立播放模式(当服务器错误或超时时调用)
196
+ * 此模式下,音频会独立播放,不依赖动画数据
197
+ * 一旦启用,本次会话后续的动画数据将被忽略
198
+ * @private
199
+ */
72
200
  private enableAudioOnlyMode;
201
+ /**
202
+ * 音频独立播放(完全独立的逻辑,不影响正常播放流程)
203
+ * @private
204
+ */
73
205
  private startAudioOnlyPlayback;
206
+ /**
207
+ * 音频监控循环(仅用于音频独立模式)
208
+ * 只检测音频是否结束,不进行动画渲染
209
+ * @private
210
+ */
74
211
  private startAudioMonitoringLoop;
212
+ /**
213
+ * Stop playback
214
+ */
75
215
  protected stopPlayback(): void;
216
+ /**
217
+ * Clean up players
218
+ */
76
219
  protected cleanupPlayers(): void;
220
+ /**
221
+ * Add audio chunk to buffer
222
+ * Note: animationPlayer should already be initialized before calling this method
223
+ */
77
224
  private addAudioChunkToBuffer;
225
+ /**
226
+ * Event system
227
+ */
78
228
  private registerEventListener;
229
+ /**
230
+ * Emit event
231
+ */
79
232
  protected emit(event: string, data?: any): void;
233
+ /**
234
+ * Apply post-processing parameters to animation parameters
235
+ * @private
236
+ */
80
237
  private applyPostProcessingToParams;
238
+ /**
239
+ * 上报 driving_service_latency 事件(Host 模式)
240
+ * 每轮会话只上报一次(在收到首帧时)
241
+ * @private
242
+ */
81
243
  private reportDrivingServiceLatency;
82
244
  }
@@ -1,5 +1,15 @@
1
+ /**
2
+ * Avatar Downloader (iOS Compatible)
3
+ * Downloads character resources from CharacterMeta structure
4
+ */
1
5
  export declare class AvatarDownloader {
2
6
  private baseAssetsPath;
3
7
  constructor(baseAssetsPath?: string);
8
+ /**
9
+ * Get AvatarKit SDK API Client (api.open.spatialwalk.top for cn, api.intl.spatialwalk.cloud for intl)
10
+ * Used for: character details and resource URLs (public endpoints, no auth required)
11
+ * Note: This endpoint does not require authentication, so we don't add X-App-Id or Authorization headers
12
+ * to avoid CORS preflight requests for simple GET requests
13
+ */
4
14
  private getSdkApiClient;
5
15
  }
@@ -7,12 +7,38 @@ export declare class AvatarManager {
7
7
  private loadingPromises;
8
8
  private downloadQueue;
9
9
  private isDownloading;
10
+ /**
11
+ * Access via global singleton
12
+ */
10
13
  static get shared(): AvatarManager;
14
+ /**
15
+ * Load avatar
16
+ * @param id Avatar ID
17
+ * @param onProgress Progress callback
18
+ * @returns Promise<Avatar>
19
+ */
11
20
  load(id: string, onProgress?: (progress: LoadProgressInfo) => void): Promise<Avatar>;
21
+ /**
22
+ * 处理下载队列(确保串行执行)
23
+ */
12
24
  private processDownloadQueue;
25
+ /**
26
+ * 执行实际的加载逻辑(私有方法)
27
+ */
13
28
  private doLoad;
29
+ /**
30
+ * Get cached avatar
31
+ * @param id Avatar ID
32
+ * @returns Avatar instance, or undefined if not in cache
33
+ */
14
34
  retrieve(id: string): Avatar | undefined;
35
+ /**
36
+ * Clear cached avatar for specified ID
37
+ * @param id Avatar ID
38
+ */
15
39
  clear(id: string): void;
40
+ /**
41
+ * Clear all avatar cache and resource loader cache
42
+ */
16
43
  clearAll(): void;
17
- clearCache(): void;
18
44
  }
@@ -5,10 +5,31 @@ export declare class AvatarSDK {
5
5
  private static readonly _version;
6
6
  private static _avatarCore;
7
7
  private static _dynamicSdkConfig;
8
+ /**
9
+ * Initialize SDK
10
+ * @param appId Application ID to be included in both HTTP Headers and WebSocket Headers
11
+ * @param configuration Configuration parameters
12
+ */
8
13
  static initialize(appId: string, configuration: Configuration): Promise<void>;
14
+ /**
15
+ * 初始化WASM模块(跟随整个SDK生命周期)
16
+ */
9
17
  private static initializeWASMModule;
18
+ /**
19
+ * 初始化模板资源(在SDK初始化时加载)
20
+ * 从全局 CDN 加载模板资源,失败时直接抛出错误,阻止SDK初始化
21
+ */
10
22
  private static initializeTemplateResources;
23
+ /**
24
+ * Set sessionToken
25
+ * Developer Client -> Developer Server -> AvatarKit Server -> return sessionToken (max 1 hour validity)
26
+ * Include in WebSocket Headers for avatar WebSocket service authentication
27
+ */
11
28
  static setSessionToken(token: string): void;
29
+ /**
30
+ * Set userId
31
+ * Optional interface for developers, SDK includes this in telemetry logs
32
+ */
12
33
  static setUserId(userId: string): void;
13
34
  static get isInitialized(): boolean;
14
35
  static get appId(): string | null;
@@ -16,6 +37,12 @@ export declare class AvatarSDK {
16
37
  static get sessionToken(): string | null;
17
38
  static get userId(): string | null;
18
39
  static get version(): string;
40
+ /**
41
+ * Cleanup resources
42
+ */
19
43
  static cleanup(): void;
44
+ /**
45
+ * 从远程配置接口获取SDK配置(已简化,逻辑移到 config/sdk-config-loader.ts)
46
+ */
20
47
  private static _fetchSdkConfig;
21
48
  }