Basic setup for Cpp based screeping.

This commit is contained in:
douwe
2025-08-12 23:56:10 +02:00
parent 7c1a84a5ca
commit 5ed1329d2e
60 changed files with 2709 additions and 604 deletions

24
js/wasm_loader.js Normal file
View File

@@ -0,0 +1,24 @@
'use strict';
module.exports = ((mod_js, mod_wasm, opts) => {
const mod_file = require(mod_js);
const bin_file = require(mod_wasm);
opts = opts || {};
opts.wasmBinary = bin_file;
opts.print = opts.print || ((text) => console.log(text));
opts.printErr = opts.printErr || ((text) => console.log(`error: ${text}`));
opts.onAbort = opts.onAbort || (() => console.log('WASM aborted!!!'));
// == don't call main()
if (typeof opts.noInitialRun === "undefined")
opts.noInitialRun = true;
// == don't terminate after returning from main()
if (typeof opts.noExitRuntime === "undefined")
opts.noExitRuntime = true;
return mod_file(opts);
});