import { CompilerService , ServiceInput , ServiceOutput } from "./types" ; import { sendRequest , ServiceTypes } from "./sendRequest" ; import { encodeBinary } from "./utils" ; export class X86Service implements CompilerService { async compile ( input ) { const files = Object . values ( input . files ) ; if ( files . length !== 1 ) { throw new Error ( `Supporting compilation of a single file, but ${ files . length } file(s) found` ) ; } const wasm = files [ 0 ] . content as ArrayBuffer ; const options = input . options ; const encodedWasm = encodeURIComponent ( encodeBinary ( wasm ) ) ; const content = await sendRequest ( "input=" + encodedWasm + "&action=wasm2assembly&options=" + encodeURIComponent ( options ) , ServiceTypes . Service ) ; return { success : true , items : { "a.json" : { content , } , } , } ; } }