MCPcopy Create free account
hub / github.com/esengine/esengine / parseAssetMeta

Function parseAssetMeta

packages/asset-system-editor/src/meta/AssetMetaFile.ts:235–252  ·  view source on GitHub ↗
(json: string)

Source from the content-addressed store, hash-verified

233 * 从 JSON 字符串解析元数据
234 */
235export 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/**

Callers 1

getOrCreateMetaMethod · 0.85

Calls 1

parseMethod · 0.65

Tested by

no test coverage detected