Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// @ts-ignore
import WasmTerminal, {
// @ts-ignore
fetchCommandFromWAPM
// @ts-ignore
} from "@wasmer/wasm-terminal";
import { WASI } from "@wasmer/wasi";
import BrowserWASIBindings from "@wasmer/wasi/bindings/browser";
// @ts-ignore
import { lowerI64Imports } from "@wasmer/wasm-transformer";
import welcomeMessage from "./welcome-message";
import { WasmFs } from "@wasmer/wasmfs";
WASI.defaultBindings = BrowserWASIBindings;
const commands = {
callback: (options: any, wasmFs: any) => {
let myArr = new Uint8Array(1024);
let stdin = wasmFs.fs.readSync(0, myArr, 0, 1024, 0);
return Promise.resolve(
`Callback Command Working! Options: ${options}, stdin: ${myArr}`
);
}
};
let didInitWasmTransformer = false;
const fetchCommandHandler = async (
commandName: string,
commandArgs?: Array,
envEntries?: any[][]
import processWorker from "@wasmer/wasm-terminal/workers/process.worker";
import { WASI } from "@wasmer/wasi";
import BrowserWASIBindings from "@wasmer/wasi/bindings/browser";
WASI.defaultBindings = BrowserWASIBindings;
export default processWorker;
async run(wasmFs: WasmFs) {
const wasi = new WASI({
preopens: {
"/": "/"
},
env: this.options.env,
args: this.options.args,
bindings: {
...WASI.defaultBindings,
fs: wasmFs.fs
}
});
let instance = await WebAssembly.instantiate(
this.options.module as WebAssembly.Module,
{
wasi_unstable: wasi.wasiImport
}
);
wasi.start(instance);
}
}