1
1
const SwiftRuntime = require ( "javascript-kit-swift" ) . SwiftRuntime ;
2
- const WasmerWASI = require ( "@wasmer/wasi" ) . WASI ;
3
- const WasmFs = require ( "@wasmer/wasmfs" ) . WasmFs ;
4
2
const NodeWASI = require ( "wasi" ) . WASI ;
5
3
const { WASI : MicroWASI , useAll } = require ( "uwasi" ) ;
6
4
@@ -9,41 +7,6 @@ const fs = require("fs");
9
7
const readFile = promisify ( fs . readFile ) ;
10
8
11
9
const 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
- } ,
47
10
MicroWASI : ( { programName } ) => {
48
11
const wasi = new MicroWASI ( {
49
12
args : [ programName ] ,
0 commit comments