Files
SpineParticlesWeb/scripts/verify-spine-connector-versions.mjs
2026-09-05 16:20:23 +08:00

32 lines
1.2 KiB
JavaScript

const connectorUrl = process.env.SPINE_CONNECTOR_URL || 'http://127.0.0.1:27843'
const origin = process.env.SPINE_CONNECTOR_TEST_ORIGIN || 'http://127.0.0.1:5173'
const versions = ['3.8', '4.0', '4.1', '4.2', '4.3']
const results = []
for (const version of versions) {
const skeleton = {
skeleton: { spine: version, images: './images/', fps: 30 },
bones: [{ name: 'root' }],
slots: [],
skins: version === '3.8' ? { default: {} } : [{ name: 'default', attachments: {} }],
animations: { animation: {} },
}
const response = await fetch(`${connectorUrl}/v1/convert`, {
method: 'POST',
headers: { Origin: origin, 'Content-Type': 'application/json' },
body: JSON.stringify({
schemaVersion: 1,
projectName: `ConnectorVersion${version.replace('.', '')}`,
spineVersion: version,
skeletonJson: JSON.stringify(skeleton),
images: [],
}),
})
if (!response.ok) throw new Error(`Spine ${version} 转换失败:${await response.text()}`)
const bytes = (await response.arrayBuffer()).byteLength
if (!bytes) throw new Error(`Spine ${version} 返回了空工程`)
results.push({ requested: version, editor: response.headers.get('x-spine-editor-version'), bytes })
}
console.log(JSON.stringify(results, null, 2))