| 233 | * 从 JSON 字符串解析元数据 |
| 234 | */ |
| 235 | export function parseAssetMeta(json: string): IAssetMeta { |
| 236 | const meta = JSON.parse(json) as IAssetMeta; |
| 237 | |
| 238 | // Validate required fields |
| 239 | if (!meta.guid || typeof meta.guid !== 'string') { |
| 240 | throw new Error('Invalid meta file: missing or invalid guid'); |
| 241 | } |
| 242 | if (!meta.type || typeof meta.type !== 'string') { |
| 243 | throw new Error('Invalid meta file: missing or invalid type'); |
| 244 | } |
| 245 | |
| 246 | // Set defaults for optional fields |
| 247 | meta.version = meta.version || 1; |
| 248 | meta.labels = meta.labels || []; |
| 249 | meta.importSettings = meta.importSettings || {}; |
| 250 | |
| 251 | return meta; |
| 252 | } |
| 253 | |
| 254 | |
| 255 | /** |