@wasmer/wasi
Advanced tools
Comparing version 1.1.2 to 1.2.0
export * from "./pkg/wasmer_wasi_js"; | ||
export declare type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module; | ||
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module; | ||
export declare const init: (input?: InitInput | Promise<InitInput>, force?: boolean) => Promise<void>; |
@@ -9,21 +9,21 @@ /** | ||
/** | ||
* @returns {BigInt} | ||
* @returns {bigint} | ||
*/ | ||
lastAccessed(): BigInt; | ||
lastAccessed(): bigint; | ||
/** | ||
* @returns {BigInt} | ||
* @returns {bigint} | ||
*/ | ||
lastModified(): BigInt; | ||
lastModified(): bigint; | ||
/** | ||
* @returns {BigInt} | ||
* @returns {bigint} | ||
*/ | ||
createdTime(): BigInt; | ||
createdTime(): bigint; | ||
/** | ||
* @returns {BigInt} | ||
* @returns {bigint} | ||
*/ | ||
size(): BigInt; | ||
size(): bigint; | ||
/** | ||
* @param {BigInt} new_size | ||
* @param {bigint} new_size | ||
*/ | ||
setLength(new_size: BigInt): void; | ||
setLength(new_size: bigint): void; | ||
/** | ||
@@ -60,2 +60,7 @@ * @returns {Uint8Array} | ||
static __wrap(ptr: any): any; | ||
/** | ||
* @param {any} jso | ||
* @returns {MemFS} | ||
*/ | ||
static from_js(jso: any): MemFS; | ||
__destroy_into_raw(): number; | ||
@@ -177,2 +182,3 @@ ptr: number; | ||
export default init; | ||
declare function init(input: any): Promise<WebAssembly.Exports>; | ||
export function initSync(module: any): any; | ||
declare function init(input: any): Promise<any>; |
{ | ||
"name": "@wasmer/wasi", | ||
"version": "1.1.2", | ||
"version": "1.2.0", | ||
"main": "dist/Library.cjs.min.js", | ||
@@ -5,0 +5,0 @@ "module": "dist/Library.esm.min.js", |
@@ -135,4 +135,4 @@ # <img height="48" src="https://raw.githubusercontent.com/wasmerio/wasmer/master/assets/logo.png" alt="Wasmer logo" valign="middle"> Wasmer JS [![Wasmer Slack Channel](https://img.shields.io/static/v1?label=chat&message=on%20Slack&color=green)](https://slack.wasmer.io) | ||
* [wasm-pack][wasm-pack] | ||
* [wabt][wabt] (for `wasm-opt`) | ||
* [binaryen][binaryen] (for `wasm-strip`) | ||
* [wabt][wabt] (for `wasm-strip`) | ||
* [binaryen][binaryen] (for `wasm-opt`) | ||
@@ -139,0 +139,0 @@ ```sh |
@@ -135,4 +135,4 @@ # <img height="48" src="https://raw.githubusercontent.com/wasmerio/wasmer/master/assets/logo.png" alt="Wasmer logo" valign="middle"> Wasmer JS [![Wasmer Slack Channel](https://img.shields.io/static/v1?label=chat&message=on%20Slack&color=green)](https://slack.wasmer.io) | ||
* [wasm-pack][wasm-pack] | ||
* [wabt][wabt] (for `wasm-opt`) | ||
* [binaryen][binaryen] (for `wasm-strip`) | ||
* [wabt][wabt] (for `wasm-strip`) | ||
* [binaryen][binaryen] (for `wasm-opt`) | ||
@@ -139,0 +139,0 @@ ```sh |
const fs = require('fs'); | ||
// const { init, WASI } = require('../'); | ||
const { init, WASI } = require('../dist/Library.cjs.js'); | ||
const { init, WASI, MemFS } = require('../dist/Library.cjs.js'); | ||
@@ -81,3 +81,3 @@ | ||
test('wasi start empty fails', async() => { | ||
test('wasi initialize with JS imports', async() => { | ||
let moduleBytes = fs.readFileSync(__dirname + '/test.wasm'); | ||
@@ -87,3 +87,2 @@ let wasi = new WASI({}); | ||
let imports = wasi.getImports(module); | ||
// console.log(imports); | ||
let instance = await WebAssembly.instantiate(module, { | ||
@@ -95,5 +94,36 @@ ...imports, | ||
}); | ||
expect(() => wasi.start()).toThrow("You need to provide a instance as argument to start, or call `wasi.instantiate` with the `WebAssembly.Instance` manually"); | ||
let code = wasi.start(instance); | ||
expect(code).toBe(0); | ||
}); | ||
test('wasi initialize with JS imports with empty start', async() => { | ||
let moduleBytes = fs.readFileSync(__dirname + '/test.wasm'); | ||
let wasi = new WASI({}); | ||
const module = await WebAssembly.compile(moduleBytes); | ||
let imports = wasi.getImports(module); | ||
let instance = await WebAssembly.instantiate(module, { | ||
...imports, | ||
'module': { | ||
'external': function() { console.log("external: hello world!") } | ||
} | ||
}); | ||
expect(() => wasi.start()).toThrow("You need to provide an instance as argument to `start`, or call `wasi.instantiate` with the `WebAssembly.Instance` manually"); | ||
}); | ||
test('wasi fs config works', async() => { | ||
let fs = new MemFS(); | ||
fs.createDir('/magic'); | ||
let wasi = new WASI({fs}); | ||
expect(wasi.fs.readDir('/').map(e => e.path)).toEqual(['/magic']); | ||
}); | ||
test('mapdir with fs config works', async () => { | ||
let wfs = new MemFS(); | ||
wfs.createDir('/magic'); | ||
let contents = fs.readFileSync(__dirname + '/mapdir.wasm'); | ||
let wasi = await initWasi(contents, {fs: wfs}); | ||
let code = wasi.start(); | ||
expect(wasi.getStdoutString()).toBe(`"./magic"\n`); | ||
}); | ||
test('get imports', async() => { | ||
@@ -115,2 +145,4 @@ let moduleBytes = fs.readFileSync(__dirname + '/test.wasm'); | ||
expect(exitCode).toBe(0); | ||
// This should print "hello world (exit code: 0)" | ||
@@ -117,0 +149,0 @@ console.log(`${stdout}(exit code: ${exitCode})`); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 2 instances in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
2
9
13
6851780
38
15691