// Copy pinned ONNX Runtime Web binaries into public/wasm so the Space self-hosts them (no third-party CDN). import { mkdirSync, copyFileSync, readFileSync } from 'node:fs'; import path from 'node:path'; const ortDir = new URL('../node_modules/onnxruntime-web/', import.meta.url).pathname; const ver = JSON.parse(readFileSync(path.join(ortDir, 'package.json'), 'utf8')).version; const out = new URL('../public/wasm/', import.meta.url).pathname; mkdirSync(out, { recursive: true }); for (const f of ['ort-wasm-simd-threaded.asyncify.mjs', 'ort-wasm-simd-threaded.asyncify.wasm', 'ort-wasm-simd-threaded.mjs', 'ort-wasm-simd-threaded.wasm']) { copyFileSync(path.join(ortDir, 'dist', f), path.join(out, f)); } console.log(`copied onnxruntime-web@${ver} wasm -> public/wasm`);