@zeewain/3d-avatar-sdk 1.2.1 → 1.2.2
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/README.md +3 -4
- package/dist/assets/Build/webgl.data.unityweb +0 -0
- package/dist/assets/Build/webgl.framework.js.unityweb +0 -0
- package/dist/assets/Build/webgl.wasm.unityweb +0 -0
- package/dist/examples/test-umd/index.html +762 -0
- package/dist/examples/test-vue2/.eslintignore +45 -0
- package/dist/examples/test-vue2/.eslintrc.js +174 -0
- package/dist/examples/test-vue2/.stylelintignore +50 -0
- package/dist/examples/test-vue2/.stylelintrc.js +79 -0
- package/dist/examples/test-vue2/README.md +139 -0
- package/dist/examples/test-vue2/babel.config.js +14 -0
- package/dist/examples/test-vue2/package.json +53 -0
- package/dist/examples/test-vue2/pnpm-lock.yaml +8776 -0
- package/dist/examples/test-vue2/public/index.html +19 -0
- package/dist/examples/test-vue2/setup.js +170 -0
- package/dist/examples/test-vue2/src/App.vue +943 -0
- package/dist/examples/test-vue2/src/components/BroadcastAPI.vue +666 -0
- package/dist/examples/test-vue2/src/components/CameraAPI.vue +414 -0
- package/dist/examples/test-vue2/src/components/GlobalConfig.vue +200 -0
- package/dist/examples/test-vue2/src/components/InfoCards.vue +294 -0
- package/dist/examples/test-vue2/src/components/InitAPI.vue +334 -0
- package/dist/examples/test-vue2/src/components/LogPanel.vue +249 -0
- package/dist/examples/test-vue2/src/components/MotionControlAPI.vue +400 -0
- package/dist/examples/test-vue2/src/components/UnityPreview.vue +201 -0
- package/dist/examples/test-vue2/src/main.js +16 -0
- package/dist/examples/test-vue2/vue.config.js +41 -0
- package/dist/examples/test-vue3/.eslintrc +3 -0
- package/dist/examples/test-vue3/.stylelintignore +3 -0
- package/dist/examples/test-vue3/.stylelintrc +48 -0
- package/dist/examples/test-vue3/README.md +236 -0
- package/dist/examples/test-vue3/env.d.ts +8 -0
- package/dist/examples/test-vue3/index.html +95 -0
- package/dist/examples/test-vue3/package.json +55 -0
- package/dist/examples/test-vue3/pnpm-lock.yaml +4636 -0
- package/dist/examples/test-vue3/setup.js +167 -0
- package/dist/examples/test-vue3/src/App.vue +962 -0
- package/dist/examples/test-vue3/src/components/BroadcastAPI.vue +636 -0
- package/dist/examples/test-vue3/src/components/CameraAPI.vue +376 -0
- package/dist/examples/test-vue3/src/components/GlobalConfig.vue +213 -0
- package/dist/examples/test-vue3/src/components/InfoCards.vue +288 -0
- package/dist/examples/test-vue3/src/components/InitAPI.vue +339 -0
- package/dist/examples/test-vue3/src/components/LogPanel.vue +236 -0
- package/dist/examples/test-vue3/src/components/MotionControlAPI.vue +373 -0
- package/dist/examples/test-vue3/src/components/UnityPreview.vue +189 -0
- package/dist/examples/test-vue3/src/main.ts +12 -0
- package/dist/examples/test-vue3/src/types.ts +9 -0
- package/dist/examples/test-vue3/tsconfig.json +44 -0
- package/dist/examples/test-vue3/tsconfig.node.json +14 -0
- package/dist/examples/test-vue3/vite.config.ts +75 -0
- package/dist/index.d.ts +15 -9
- package/dist/index.es5.js +64 -17
- package/dist/index.es5.umd.js +64 -17
- package/dist/index.esm.js +71 -16
- package/dist/index.umd.cjs +71 -16
- package/package.json +4 -3
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @fileoverview 统一的项目设置脚本 (Vue3版本)
|
|
5
|
+
* @description 根据运行环境自动设置项目,支持本地开发和npm包两种模式
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import fs from 'fs-extra'
|
|
9
|
+
import path from 'path'
|
|
10
|
+
import { execSync } from 'child_process'
|
|
11
|
+
|
|
12
|
+
// 路径配置
|
|
13
|
+
const PROJECT_ROOT = process.cwd()
|
|
14
|
+
const SDK_ROOT = path.resolve(PROJECT_ROOT, '../../')
|
|
15
|
+
const SDK_DIST = path.resolve(SDK_ROOT, 'dist')
|
|
16
|
+
const NPM_SDK_ASSETS = path.resolve(PROJECT_ROOT, 'node_modules/@zeewain/3d-avatar-sdk/dist/assets')
|
|
17
|
+
const LOCAL_ASSETS_TARGET = path.resolve(PROJECT_ROOT, 'public/assets')
|
|
18
|
+
const ENV_FILE = path.resolve(PROJECT_ROOT, '.env.local')
|
|
19
|
+
|
|
20
|
+
// 解析命令行参数
|
|
21
|
+
const args = process.argv.slice(2)
|
|
22
|
+
const isDev = args.includes('--dev') || args.includes('-d')
|
|
23
|
+
const isProduction = args.includes('--prod') || args.includes('-p')
|
|
24
|
+
const mode = isDev ? 'dev' : (isProduction ? 'prod' : 'auto')
|
|
25
|
+
|
|
26
|
+
console.log('🚀 设置 3D数字人SDK Vue3 测试项目...')
|
|
27
|
+
console.log(`📁 项目目录: ${PROJECT_ROOT}`)
|
|
28
|
+
console.log(`🔧 运行模式: ${mode}`)
|
|
29
|
+
console.log('')
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* 检测应该使用的模式
|
|
33
|
+
* @returns {'dev'|'npm'} 返回检测到的模式
|
|
34
|
+
*/
|
|
35
|
+
function detectMode() {
|
|
36
|
+
// 如果明确指定了模式,使用指定的模式
|
|
37
|
+
if (isDev) return 'dev'
|
|
38
|
+
if (isProduction) return 'npm'
|
|
39
|
+
|
|
40
|
+
// 自动检测:如果父目录存在SDK源码,优先使用开发模式
|
|
41
|
+
const sdkSourceExists = fs.existsSync(path.resolve(SDK_ROOT, 'src'))
|
|
42
|
+
|
|
43
|
+
if (sdkSourceExists) {
|
|
44
|
+
console.log('✅ 检测到本地SDK源码,将使用开发模式')
|
|
45
|
+
return 'dev'
|
|
46
|
+
} else {
|
|
47
|
+
console.log('📦 未检测到本地SDK源码,将使用npm包模式')
|
|
48
|
+
return 'npm'
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* 设置开发环境(使用本地SDK源码)
|
|
54
|
+
*/
|
|
55
|
+
async function setupDevEnvironment() {
|
|
56
|
+
console.log('🔧 设置本地开发环境...')
|
|
57
|
+
|
|
58
|
+
try {
|
|
59
|
+
// 1. 检查并构建SDK
|
|
60
|
+
if (!fs.existsSync(SDK_DIST)) {
|
|
61
|
+
console.log('⚠️ SDK构建目录不存在,正在构建...')
|
|
62
|
+
execSync('npm run build', { cwd: SDK_ROOT, stdio: 'inherit' })
|
|
63
|
+
} else {
|
|
64
|
+
console.log('✅ SDK构建目录已存在')
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// 2. 复制本地SDK的assets文件
|
|
68
|
+
const localSdkAssetsPath = path.resolve(SDK_DIST, 'assets')
|
|
69
|
+
if (fs.existsSync(localSdkAssetsPath)) {
|
|
70
|
+
console.log('📋 复制本地SDK构建文件...', localSdkAssetsPath, LOCAL_ASSETS_TARGET)
|
|
71
|
+
await fs.copy(localSdkAssetsPath, LOCAL_ASSETS_TARGET)
|
|
72
|
+
console.log('✅ 本地SDK构建文件复制完成')
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// 3. 创建开发环境配置
|
|
76
|
+
console.log('📝 设置开发环境变量...')
|
|
77
|
+
const envContent = `# 本地开发环境配置
|
|
78
|
+
# 使用本地SDK版本而不是npm版本
|
|
79
|
+
VITE_USE_LOCAL_SDK=true
|
|
80
|
+
|
|
81
|
+
# 本地SDK路径信息(仅供参考)
|
|
82
|
+
VITE_LOCAL_SDK_PATH=${SDK_DIST}
|
|
83
|
+
|
|
84
|
+
# 开发模式标识
|
|
85
|
+
NODE_ENV=development
|
|
86
|
+
VITE_APP_ENV=development
|
|
87
|
+
|
|
88
|
+
# Unity资源文件路径
|
|
89
|
+
VITE_ASSETS_PATH=/assets
|
|
90
|
+
`
|
|
91
|
+
|
|
92
|
+
await fs.writeFile(ENV_FILE, envContent)
|
|
93
|
+
console.log(`✅ 已创建开发环境配置: ${ENV_FILE}`)
|
|
94
|
+
} catch (error) {
|
|
95
|
+
console.error('❌ 开发环境设置失败:', error.message)
|
|
96
|
+
throw error
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* 设置生产环境(使用npm包)
|
|
102
|
+
*/
|
|
103
|
+
async function setupProductionEnvironment() {
|
|
104
|
+
console.log('📦 设置npm包环境...')
|
|
105
|
+
|
|
106
|
+
try {
|
|
107
|
+
// 1. 复制npm包中的assets文件
|
|
108
|
+
if (fs.existsSync(NPM_SDK_ASSETS)) {
|
|
109
|
+
console.log('📋 复制npm包构建文件...')
|
|
110
|
+
await fs.copy(NPM_SDK_ASSETS, LOCAL_ASSETS_TARGET)
|
|
111
|
+
console.log('✅ npm包构建文件复制完成')
|
|
112
|
+
} else {
|
|
113
|
+
console.log('⚠️ 警告: 未找到npm包中的Unity构建文件')
|
|
114
|
+
console.log(' 请确保已安装 @zeewain/3d-avatar-sdk 包')
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// 2. 创建生产环境配置
|
|
118
|
+
console.log('📝 设置生产环境变量...')
|
|
119
|
+
const envContent = `# 生产环境配置
|
|
120
|
+
# 使用npm包版本
|
|
121
|
+
VITE_USE_LOCAL_SDK=false
|
|
122
|
+
|
|
123
|
+
# 生产模式标识
|
|
124
|
+
NODE_ENV=production
|
|
125
|
+
VITE_APP_ENV=production
|
|
126
|
+
|
|
127
|
+
# Unity资源文件路径
|
|
128
|
+
VITE_ASSETS_PATH=/assets
|
|
129
|
+
`
|
|
130
|
+
|
|
131
|
+
await fs.writeFile(ENV_FILE, envContent)
|
|
132
|
+
console.log(`✅ 已创建生产环境配置: ${ENV_FILE}`)
|
|
133
|
+
} catch (error) {
|
|
134
|
+
console.error('❌ 生产环境设置失败:', error.message)
|
|
135
|
+
throw error
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* 主设置函数
|
|
141
|
+
*/
|
|
142
|
+
async function setup() {
|
|
143
|
+
try {
|
|
144
|
+
const detectedMode = detectMode()
|
|
145
|
+
|
|
146
|
+
if (detectedMode === 'dev') {
|
|
147
|
+
await setupDevEnvironment()
|
|
148
|
+
} else {
|
|
149
|
+
await setupProductionEnvironment()
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
console.log('')
|
|
153
|
+
console.log('🎉 项目设置完成!')
|
|
154
|
+
console.log('💡 提示:')
|
|
155
|
+
console.log(' - 使用 "npm run dev" 启动开发服务器')
|
|
156
|
+
console.log(' - 使用 "npm run build" 构建项目')
|
|
157
|
+
console.log(' - 使用 "npm run preview" 预览构建结果')
|
|
158
|
+
console.log('')
|
|
159
|
+
|
|
160
|
+
} catch (error) {
|
|
161
|
+
console.error('❌ 项目设置失败:', error.message)
|
|
162
|
+
process.exit(1)
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// 运行设置
|
|
167
|
+
setup()
|