feat: add a histrical wit-bindgen

This commit is contained in:
2023-01-01 00:25:48 +08:00
parent 01e8f5a959
commit aa50d63aec
419 changed files with 45283 additions and 1 deletions

View File

@@ -0,0 +1,26 @@
import { readFileSync } from 'fs';
import { WASI } from 'wasi';
export function getWasm() {
return readFileSync(process.argv[2]);
}
class MyWasi {
constructor(wasi) {
this.wasi = wasi;
}
start(instance) {
if ('_start' in instance.exports) {
this.wasi.start(instance);
} else {
this.wasi.initialize(instance);
}
}
}
export function addWasiToImports(importObj) {
const wasi = new WASI();
importObj.wasi_snapshot_preview1 = wasi.wasiImport;
return new MyWasi(wasi);
}