11const SwiftRuntime = require ( "javascript-kit-swift" ) . SwiftRuntime ;
2- const WasmerWASI = require ( "@wasmer/wasi" ) . WASI ;
3- const WasmFs = require ( "@wasmer/wasmfs" ) . WasmFs ;
42const NodeWASI = require ( "wasi" ) . WASI ;
53const { WASI : MicroWASI , useAll } = require ( "uwasi" ) ;
64
@@ -9,41 +7,6 @@ const fs = require("fs");
97const readFile = promisify ( fs . readFile ) ;
108
119const WASI = {
12- Wasmer : ( { programName } ) => {
13- // Instantiate a new WASI Instance
14- const wasmFs = new WasmFs ( ) ;
15- // Output stdout and stderr to console
16- const originalWriteSync = wasmFs . fs . writeSync ;
17- wasmFs . fs . writeSync = ( fd , buffer , offset , length , position ) => {
18- const text = new TextDecoder ( "utf-8" ) . decode ( buffer ) ;
19- switch ( fd ) {
20- case 1 :
21- console . log ( text ) ;
22- break ;
23- case 2 :
24- console . error ( text ) ;
25- break ;
26- }
27- return originalWriteSync ( fd , buffer , offset , length , position ) ;
28- } ;
29- const wasi = new WasmerWASI ( {
30- args : [ programName ] ,
31- env : { } ,
32- bindings : {
33- ...WasmerWASI . defaultBindings ,
34- fs : wasmFs . fs ,
35- } ,
36- } ) ;
37-
38- return {
39- wasiImport : wasi . wasiImport ,
40- start ( instance ) {
41- wasi . start ( instance ) ;
42- instance . exports . _initialize ( ) ;
43- instance . exports . main ( ) ;
44- }
45- }
46- } ,
4710 MicroWASI : ( { programName } ) => {
4811 const wasi = new MicroWASI ( {
4912 args : [ programName ] ,
0 commit comments