const fs = require("fs"); const path = require("path"); const { pathToFileURL } = require("url"); const build = path.resolve(process.argv[2] || "build-web/configure/bin"); async function main() { globalThis.__dirname = `${build}${path.sep}`; globalThis.require = require; const loader = await import(pathToFileURL(path.join(build, "FreeCADWebPartDesignRuntimeProbe.js"))); const probe = await loader.default({ wasmBinary: fs.readFileSync(path.join(build, "FreeCADWebPartDesignRuntimeProbe.wasm")) }); const call = (name, type = "number") => probe.ccall(name, type); const run = call("fc_web_partdesign_save_reopen"); const result = { run, error: call("fc_web_partdesign_persistence_error", "string"), path: call("fc_web_partdesign_persistence_path", "string"), objectType: call("fc_web_partdesign_persistence_object_type", "string"), beforeVolume: call("fc_web_partdesign_persistence_before_volume"), afterVolume: call("fc_web_partdesign_persistence_after_volume"), size: call("fc_web_partdesign_persistence_size"), objectCount: call("fc_web_partdesign_persistence_object_count") }; if (result.run !== 1 || result.error !== "" || result.path !== "/tmp/PartDesignWeb.FCStd" || result.objectType !== "PartDesign::AdditiveBox" || result.size <= 0 || result.objectCount !== 2 || Math.abs(result.beforeVolume - result.afterVolume) > 1e-9 || Math.abs(result.afterVolume - 24) > 1e-9) throw new Error(JSON.stringify(result)); console.log(JSON.stringify({ result: "pass", action: "save/reopen", ...result })); } main().catch((error) => { console.error(error); process.exitCode = 1; });