Files
SpineViewer/js/eagle-compound.js
2026-09-10 13:53:43 +08:00

18 lines
641 B
JavaScript

'use strict';
const path = require('path');
// Preserve name + '.' + ext exactly; only split the compound suffix correctly.
// Return through Eagle's thumbnail callback so Eagle persists its own metadata.
function normalizeItem(src, item) {
const filename = path.basename(src);
const match = filename.match(/^(.*)\.(atlas\.txt|skel\.bytes)$/i);
if (!match || !item || !item.ext) return false;
if (item.name + '.' + item.ext !== filename) return false;
if (item.name === match[1] && item.ext === match[2]) return false;
item.name = match[1]; item.ext = match[2];
delete item.text;
return true;
}
module.exports = { normalizeItem };