WIP: WASM port - switch to ncruces/go-sqlite3, add WASM stubs
- Switched from modernc.org/sqlite to ncruces/go-sqlite3 for WASM support - Added WASM-specific stubs for daemon process management - Created wasm/ directory with build.sh and Node.js runner - WASM build succeeds (32MB bd.wasm) - Node.js can load and execute the WASM module - Next: Need to bridge Go file I/O to Node.js fs module Related: bd-44d0, bd-8534, bd-c7eb
This commit is contained in:
28
wasm/run.js
Normal file
28
wasm/run.js
Normal file
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env node
|
||||
// Node.js wrapper for bd.wasm
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
// Load wasm_exec.js from Go distribution
|
||||
require('./wasm_exec.js');
|
||||
|
||||
// Load the WASM binary
|
||||
const wasmPath = path.join(__dirname, 'bd.wasm');
|
||||
const wasmBuffer = fs.readFileSync(wasmPath);
|
||||
|
||||
// Create Go runtime instance
|
||||
const go = new Go();
|
||||
|
||||
// Pass command-line arguments to Go
|
||||
// process.argv[0] is 'node', process.argv[1] is this script
|
||||
// So we want process.argv.slice(1) to simulate: bd <args>
|
||||
go.argv = ['bd'].concat(process.argv.slice(2));
|
||||
|
||||
// Instantiate and run the WASM module
|
||||
WebAssembly.instantiate(wasmBuffer, go.importObject).then((result) => {
|
||||
go.run(result.instance);
|
||||
}).catch((err) => {
|
||||
console.error('Failed to run WASM:', err);
|
||||
process.exit(1);
|
||||
});
|
||||
Reference in New Issue
Block a user