'use strict'; // Local visual diagnostic. The private project/export remain outside version control. const fs = require('fs'), path = require('path'); const root = path.resolve(__dirname, '..'); const source = process.argv[2]; if (!source) throw Error('Usage: node tests/build-x10-comparison.js x10.skel [x10.atlas] [x10.png] [output.html]'); const assets = require('../js/spine-utils').discoverAssets(source); const atlasPath = process.argv[3] || assets.atlasPath; const texturePath = process.argv[4] || assets.texturePaths['x10.png']; const output = process.argv[5] || '/tmp/spine-x10-comparison.html'; const baseline = process.env.SPINE_COMPARE_BASELINE === '1'; const script = s => ''; let html = '
RUNNING'; html += script('var module={exports:{}};const modules={};function require(n){return modules[n]}'); for (const name of ['spine-webgl-rasterizer', 'spine-canvas-clipping']) html += script('module={exports:{}};\n' + (baseline ? require('child_process').execFileSync('git',['show','HEAD:js/'+name+'.js'],{cwd:root,encoding:'utf8'}) : fs.readFileSync(path.join(root, 'js', name+'.js'), 'utf8')) + `\nmodules['./${name}.js']=module.exports;`); html += script(fs.readFileSync(path.join(root, 'lib/4.2/spine-canvas.js'), 'utf8')); html += script(`(async()=>{try{ const raw=Uint8Array.from(atob('${fs.readFileSync(texturePath).toString('base64')}'),c=>c.charCodeAt(0)); const image=new Image();image.src='data:image/png;base64,${fs.readFileSync(texturePath).toString('base64')}';await image.decode(); if(modules['./spine-webgl-rasterizer.js'].prepareTexture) await modules['./spine-webgl-rasterizer.js'].prepareTexture(image,new Blob([raw],{type:'image/png'})); const atlas=new spine.TextureAtlas(${JSON.stringify(fs.readFileSync(atlasPath,'utf8'))});for(const page of atlas.pages)page.setTexture(new spine.CanvasTexture(image)); const data=new spine.SkeletonBinary(new spine.AtlasAttachmentLoader(atlas)).readSkeletonData(Uint8Array.from(atob('${fs.readFileSync(source).toString('base64')}'),c=>c.charCodeAt(0))); const reference=new Image();reference.src='data:image/png;base64,${fs.readFileSync(path.join(__dirname,'对比测试.png')).toString('base64')}';await reference.decode(); const reports=[]; function panel(name){const e=document.createElement('section');e.innerHTML='