// Independent offline library replacement probe; no portal/account/network calls. const fs = require('node:fs'); const path = require('node:path'); async function main() { if (process.argv.length !== 5) { throw new Error('Usage: node verify-replacement.cjs /path/glue.js /path/library.wasm /path/synthetic.step'); } const [glue, wasm, model] = process.argv.slice(2).map(p => path.resolve(p)); const initialize = require(glue); const importer = await initialize({ wasmBinary: new Uint8Array(fs.readFileSync(wasm)), locateFile: () => wasm, print: () => {}, printErr: () => {}, }); const result = importer.ReadStepFile(new Uint8Array(fs.readFileSync(model)), { linearUnit: 'millimeter', linearDeflectionType: 'bounding_box_ratio', linearDeflection: 0.001, angularDeflection: 0.5, }); const triangles = (result.meshes || []).reduce((n, mesh) => n + (mesh.index?.array?.length || 0) / 3, 0); if (!result.success || !triangles) throw new Error('Replacement could not produce mesh triangles'); console.log(JSON.stringify({success: true, meshes: result.meshes.length, triangles})); } main().catch(error => { console.error(error.message); process.exitCode = 1; });