@spatialwalk/avatarkit 1.0.0-beta.67 → 1.0.0-beta.68

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
@@ -2,6 +2,15 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [1.0.0-beta.68] - 2026-01-17
6
+
7
+ ### 🐛 Bugfixes
8
+ - **Vite Plugin WASM File Detection** - Fixed Vite plugin not finding WASM files with hash in consuming projects
9
+ - Plugin now reads JS glue file to extract referenced WASM filename (including hash)
10
+ - Ensures correct WASM file is copied to match JS glue file references
11
+ - Prevents 404 errors when WASM files have content-based hashes
12
+ - Fixes issue where `avatar_core_wasm.wasm` was not found after adding hash support
13
+
5
14
  ## [1.0.0-beta.67] - 2026-01-17
6
15
 
7
16
  ### 🐛 Bugfixes
@@ -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-GRm00rtd.js";
4
+ import { A as APP_CONFIG, l as logger, e as errorToMessage, a as logEvent } from "./index-CF8Fvg7k.js";
5
5
  class StreamingAudioPlayer {
6
6
  constructor(options) {
7
7
  __publicField(this, "audioContext", null);
@@ -7624,7 +7624,7 @@ const _AnimationPlayer = class _AnimationPlayer {
7624
7624
  if (this.streamingPlayer) {
7625
7625
  return;
7626
7626
  }
7627
- const { StreamingAudioPlayer } = await import("./StreamingAudioPlayer-CD9jBs6B.js");
7627
+ const { StreamingAudioPlayer } = await import("./StreamingAudioPlayer-DrTBMLSq.js");
7628
7628
  const { AvatarSDK: AvatarSDK2 } = await Promise.resolve().then(() => AvatarSDK$1);
7629
7629
  const audioFormat = AvatarSDK2.getAudioFormat();
7630
7630
  this.streamingPlayer = new StreamingAudioPlayer({
@@ -8961,7 +8961,7 @@ class AvatarSDK {
8961
8961
  }
8962
8962
  __publicField(AvatarSDK, "_isInitialized", false);
8963
8963
  __publicField(AvatarSDK, "_configuration", null);
8964
- __publicField(AvatarSDK, "_version", "1.0.0-beta.67");
8964
+ __publicField(AvatarSDK, "_version", "1.0.0-beta.68");
8965
8965
  __publicField(AvatarSDK, "_avatarCore", null);
8966
8966
  __publicField(AvatarSDK, "_dynamicSdkConfig", null);
8967
8967
  const AvatarSDK$1 = Object.freeze(Object.defineProperty({
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { b, c, m, f, d, j, g, C, i, D, E, k, h, L, R, n } from "./index-GRm00rtd.js";
1
+ import { b, c, m, f, d, j, g, C, i, D, E, k, h, L, R, n } from "./index-CF8Fvg7k.js";
2
2
  export {
3
3
  b as Avatar,
4
4
  c as AvatarController,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@spatialwalk/avatarkit",
3
3
  "type": "module",
4
- "version": "1.0.0-beta.67",
4
+ "version": "1.0.0-beta.68",
5
5
  "packageManager": "pnpm@10.18.2",
6
6
  "description": "SPAvatar SDK - 3D Gaussian Splatting Avatar Rendering SDK",
7
7
  "author": "SPAvatar Team",
package/vite.js CHANGED
@@ -1,4 +1,4 @@
1
- import { copyFileSync, existsSync, writeFileSync, readdirSync } from 'node:fs';
1
+ import { copyFileSync, existsSync, writeFileSync, readdirSync, readFileSync } from 'node:fs';
2
2
  import { join } from 'node:path';
3
3
  /**
4
4
  * Vite plugin for @spatialwalk/avatarkit
@@ -37,43 +37,59 @@ export function avatarkitVitePlugin() {
37
37
  closeBundle() {
38
38
  if (!rootDir)
39
39
  return;
40
- // 查找 node_modules 中的 WASM 文件
41
- const wasmSource = join(rootDir, 'node_modules/@spatialwalk/avatarkit/dist/avatar_core_wasm.wasm');
42
- // 查找 node_modules 中的 WASM JS glue 文件
43
- // 注意:Vite 可能会给 JS 文件加 hash,所以我们需要查找所有可能的文件
44
- const wasmJsSourcePattern = join(rootDir, 'node_modules/@spatialwalk/avatarkit/dist');
45
- // 目标路径 - 根据实际使用情况,WASM 文件应该在 assets 目录
46
- // 因为 Vite 通常会把资源放在 assets 目录,而 SDK 代码使用相对路径导入
47
- const wasmDest = join(rootDir, 'dist/assets/avatar_core_wasm.wasm');
40
+ const wasmSourceDir = join(rootDir, 'node_modules/@spatialwalk/avatarkit/dist');
41
+ // 先查找并读取 JS glue 文件,提取它引用的 WASM 文件名
42
+ let wasmFileName = null;
43
+ if (existsSync(wasmSourceDir)) {
44
+ const files = readdirSync(wasmSourceDir);
45
+ const wasmJsFile = files.find((f) => f.startsWith('avatar_core_wasm') && f.endsWith('.js'));
46
+ if (wasmJsFile) {
47
+ const wasmJsSource = join(wasmSourceDir, wasmJsFile);
48
+ try {
49
+ const jsContent = readFileSync(wasmJsSource, 'utf-8');
50
+ // 从 JS 文件中提取 WASM 文件名
51
+ // 匹配 avatar_core_wasm-{hash}.wasm 或 avatar_core_wasm.wasm
52
+ // 使用更精确的正则,匹配带引号或不带引号的情况
53
+ const wasmMatch = jsContent.match(/["'`]?avatar_core_wasm[-\w]*\.wasm["'`]?/g);
54
+ if (wasmMatch && wasmMatch.length > 0) {
55
+ // 取第一个匹配,去掉引号
56
+ wasmFileName = wasmMatch[0].replace(/["'`]/g, '');
57
+ }
58
+ }
59
+ catch (error) {
60
+ console.warn('⚠️ [avatarkit] Could not read JS glue file:', error);
61
+ }
62
+ }
63
+ }
64
+ // 如果从 JS 文件中找到了 WASM 文件名,使用它;否则回退到默认名称
65
+ const targetWasmName = wasmFileName || 'avatar_core_wasm.wasm';
66
+ const wasmSource = join(wasmSourceDir, targetWasmName);
67
+ const wasmDest = join(rootDir, `dist/assets/${targetWasmName}`);
48
68
  const wasmJsDest = join(rootDir, 'dist/assets/avatar_core_wasm.js');
49
69
  const headersDest = join(rootDir, 'dist/_headers');
50
70
  // 复制 WASM 文件
51
71
  if (existsSync(wasmSource)) {
52
72
  copyFileSync(wasmSource, wasmDest);
53
- console.log('✅ [avatarkit] Copied WASM file to dist/assets/avatar_core_wasm.wasm');
73
+ console.log(`✅ [avatarkit] Copied WASM file to dist/assets/${targetWasmName}`);
54
74
  }
55
75
  else {
56
- console.warn('⚠️ [avatarkit] WASM file not found at:', wasmSource);
57
- }
58
- // 尝试查找并复制 WASM JS glue 文件
59
- // 由于 Vite 可能会给文件加 hash,我们尝试查找匹配的文件
60
- try {
61
- if (existsSync(wasmJsSourcePattern)) {
62
- const files = readdirSync(wasmJsSourcePattern);
63
- const wasmJsFile = files.find((f) => f.startsWith('avatar_core_wasm') && f.endsWith('.js'));
64
- if (wasmJsFile) {
65
- const wasmJsSource = join(wasmJsSourcePattern, wasmJsFile);
66
- copyFileSync(wasmJsSource, wasmJsDest);
67
- console.log(`✅ [avatarkit] Copied WASM JS file to dist/assets/avatar_core_wasm.js (from ${wasmJsFile})`);
68
- }
69
- else {
70
- console.log('ℹ️ [avatarkit] WASM JS file not found (may be handled by Vite):', wasmJsSourcePattern);
71
- }
76
+ console.warn(`⚠️ [avatarkit] WASM file not found: ${wasmSource}`);
77
+ if (wasmFileName) {
78
+ console.warn(` Expected file: ${targetWasmName} (extracted from JS glue file)`);
72
79
  }
73
80
  }
74
- catch (error) {
75
- // 如果读取目录失败,不报错,因为 Vite 可能已经处理了 JS 文件
76
- console.log('ℹ️ [avatarkit] Could not find WASM JS file (may be handled by Vite)');
81
+ // 复制 WASM JS glue 文件
82
+ if (existsSync(wasmSourceDir)) {
83
+ const files = readdirSync(wasmSourceDir);
84
+ const wasmJsFile = files.find((f) => f.startsWith('avatar_core_wasm') && f.endsWith('.js'));
85
+ if (wasmJsFile) {
86
+ const wasmJsSource = join(wasmSourceDir, wasmJsFile);
87
+ copyFileSync(wasmJsSource, wasmJsDest);
88
+ console.log(`✅ [avatarkit] Copied WASM JS file to dist/assets/avatar_core_wasm.js (from ${wasmJsFile})`);
89
+ }
90
+ else {
91
+ console.log('ℹ️ [avatarkit] WASM JS file not found (may be handled by Vite):', wasmSourceDir);
92
+ }
77
93
  }
78
94
  // 生成 _headers 文件(用于 Cloudflare Pages 等平台)
79
95
  const headersContent = '/*.wasm\n Content-Type: application/wasm\n';