{"name":"@wasmer/wasi","version":"1.1.2","keywords":["webassembly","wasm","wasi"],"author":{"name":"Wasmer Engineering Team","email":"engineering@wasmer.io"},"license":"MIT","_id":"@wasmer/wasi@1.1.2","maintainers":[{"name":"syrusakbary","email":"me@syrusakbary.com"}],"homepage":"https://github.com/wasmerio/wasmer-js","bugs":{"url":"https://github.com/wasmerio/wasmer-js/issues"},"dist":{"shasum":"c99faf45bfc7ff464dfd4bec661320c4073c268b","tarball":"http://registry-npm.ywwl.com/@wasmer/wasi/download/@wasmer/wasi-1.1.2.tgz","fileCount":71,"integrity":"sha512-c1h7L2qPviV6n+ny2fYboFPFL4RbvCqYckDPfpWMUOqX+QIt83EnMnYfeWNwWbUAIku087qj3cBJzcqY+HbHxw==","signatures":[{"sig":"MEUCIHAuMJ2L/Cv9cQIlhc9QEeBGjT+hel3Ibj1Egs9Pf2YQAiEA6KdsNgCzcaRtF0FePBkY74FrDS46n/oxBLdBFjgDY2w=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16159524,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjEQX9ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqydQ//ao+s0ZvU4MIPk6hWnT7gbKZL9uFvsoT1NZebzgZ4BIn356GU\r\n4lODhIujHIUdBK6CTAgDJmuKWoNhDChC7/a/8XCgPNePyohXwx7SEQ4rUB9g\r\nMdywgNrgSf8Egz2XWY5evi1AGgUQEm7o8RC1teTSNOj8BwW3nkmj4lOJWPE6\r\nCbEqPo/lV5doHV8p0kPcM6X/bP9Hj6g23dMIkVkkQpu12r2V+0QBvkc1Ttiw\r\nEvRkLxPuwaz6reyw5HQh1MlNag+aV+ONCkGu5bRwR7rfVGlGdycme3sT49So\r\nPM45Iv3Z4AQpAlxC/7zPfxcXclJL5tbGizEWbKgTFTdKPbTkJoDQ6XM89KVM\r\n3JBVH3Y//8nl3Zr00EDNVcRTOIhh/JuHq2LzcD+YDjo7Y8KNI9mVAu8iKocI\r\nNKoBtaxdDj/O6q06lFGqpNa75e3KVPfarTBQqYsxFqTKZZLY8rpC170AZ1hG\r\nIUjCRoqlR6VU4viGm2k2x3UtXhXZ384B4iH6KdhRLRuVAt2dn52EHd52VwDS\r\nt7dB9cYbCp/asf4+dFZFfQn4dihOm7DPHcfOIR0YUHVWbH6jrH2Nec/S4UW8\r\nsR8nkwafajqOCBHCuAP3QDpCHF4aQVxm8yGkPJKe7OL6s0hPwEvouByTO8CR\r\nXrCstSyWsoxJNaoCQ2uXUSGSQk+2vSEfnGw=\r\n=TlMr\r\n-----END PGP SIGNATURE-----\r\n","size":4756663,"noattachment":false,"key":"/@wasmer/wasi/-/@wasmer/wasi-1.1.2.tgz"},"main":"dist/Library.cjs.min.js","unpkg":"dist/Library.umd.min.js","module":"dist/Library.esm.min.js","gitHead":"cfb2ca79a4fe9649cdd5c9c4b35c9ba3623c640f","scripts":{"dev":"rollup -c -w","lint":"","test":"jest -c jest.config.js","build":"wasm-pack build --release --target web; wasm-opt pkg/wasmer_wasi_js_bg.wasm -O2 -o pkg/wasmer_wasi_js_bg.wasm; wasm-strip pkg/wasmer_wasi_js_bg.wasm; rollup -c --environment BUILD:production","clean":"rimraf dist coverage","prepare":"npm-run-all clean lint build test","test:watch":"npm run test -- --watch","test:coverage":"npm run test -- --coverage"},"_npmUser":{"name":"syrusakbary","email":"me@syrusakbary.com"},"repository":{"url":"git+https://github.com/wasmerio/wasmer-js.git","type":"git"},"_npmVersion":"8.11.0","description":"Isomorphic Javascript library for interacting with WASI Modules in Node.js and the Browser.","directories":{},"_nodeVersion":"16.16.0","browserslist":"> 0.5%, last 2 versions, Firefox ESR, not dead","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^27.3.1","tslib":"^2.3.1","eslint":"~7.18.0","rimraf":"~3.0.2","rollup":"~2.60.0","cross-env":"~7.0.3","ts-loader":"^9.2.6","typescript":"^4.5.2","@babel/core":"~7.16.0","npm-run-all":"~4.1.5","@babel/register":"~7.16.0","@babel/preset-env":"~7.16.0","@rollup/plugin-url":"^6.1.0","@rollup/plugin-wasm":"^5.1.2","@rollup/plugin-babel":"~5.3.0","rollup-plugin-terser":"~7.0.2","@rollup/plugin-commonjs":"~21.0.1","rollup-plugin-typescript2":"^0.31.0","@rollup/plugin-node-resolve":"~13.0.6","@wasm-tool/wasm-pack-plugin":"1.6.0","@babel/plugin-proposal-object-rest-spread":"~7.16.0"},"_npmOperationalInternal":{"tmp":"tmp/wasi_1.1.2_1662060029465_0.3597115934270596","host":"s3://npm-registry-packages"},"readme":"# <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)\n\nThis repository consists of multiple packages:\n* [Wasmer WASI](#wasmer-wasi)\n\n# Wasmer WASI\n\nIsomorphic Javascript library for interacting with WASI Modules in Node.js, the Browser and [Deno](https://deno.land/x/wasm).\nThe Javascript Package supports:\n* [X] WASI (with command args, envs and stdio)\n* [X] In-Memory filesystem (MemFS)\n\n### NPM\n\nFor instaling `@wasmer/wasi` run this command in your shell:\n\n```bash\nnpm install --save @wasmer/wasi\n```\n\nAnd then import it in your server or client-side code with:\n\n```js\nimport { init, WASI } from '@wasmer/wasi';\n```\n\n> Check the Node usage examples in https://github.com/wasmerio/wasmer-js/tree/main/examples/node\n\n### Deno\n\nThis package is published in Deno in the `wasm` package, you can import it directly with:\n\n```ts\nimport { init, WASI } from 'https://deno.land/x/wasm/wasi.ts';\n```\n\n> Check the Deno usage Examples in https://github.com/wasmerio/wasmer-js/tree/main/examples/deno\n\n## Usage\n\n```js\n// This is needed to load the WASI library first (since is a Wasm module)\nawait init();\n\nlet wasi = new WASI({\n  env: {\n      // 'ENVVAR1': '1',\n      // 'ENVVAR2': '2'\n  },\n  args: [\n      // 'command', 'arg1', 'arg2'\n  ],\n});\n\nconst moduleBytes = fetch(\"https://deno.land/x/wasm/tests/demo.wasm\");\nconst module = await WebAssembly.compileStreaming(moduleBytes);\n// Instantiate the WASI module\nawait wasi.instantiate(module, {});\n\n// Run the start function\nlet exitCode = wasi.start();\nlet stdout = wasi.getStdoutString();\n\n // This should print \"hello world (exit code: 0)\"\nconsole.log(`${stdout}(exit code: ${exitCode})`);\n```\n\n## API Docs\n\n<!-- Please check the full API documents here:\nhttps://docs.wasmer.io/integrations/js/reference-api -->\n\n### Typescript API\n\n```typescript\nexport class WASI {\n  constructor(config: any);\n  readonly fs: MemFS;\n\n  instantiate(module: any, imports: object): WebAssembly.Instance;\n  // Start the WASI Instance, it returns the status code when calling the start\n  // function\n  start(instance: WebAssembly.Instance): number;\n  // Get the stdout buffer\n  // Note: this method flushes the stdout\n  getStdoutBuffer(): Uint8Array;\n  // Get the stdout data as a string\n  // Note: this method flushes the stdout\n  getStdoutString(): string;\n  // Get the stderr buffer\n  // Note: this method flushes the stderr\n  getStderrBuffer(): Uint8Array;\n  // Get the stderr data as a string\n  // Note: this method flushes the stderr\n  getStderrString(): string;\n  // Set the stdin buffer\n  setStdinBuffer(buf: Uint8Array): void;\n  // Set the stdin data as a string\n  setStdinString(input: string): void;\n}\n\nexport class MemFS {\n  constructor();\n  readDir(path: string): Array<any>;\n  createDir(path: string): void;\n  removeDir(path: string): void;\n  removeFile(path: string): void;\n  rename(path: string, to: string): void;\n  metadata(path: string): object;\n  open(path: string, options: any): JSVirtualFile;\n}\n\nexport class JSVirtualFile {\n  lastAccessed(): BigInt;\n  lastModified(): BigInt;\n  createdTime(): BigInt;\n  size(): BigInt;\n  setLength(new_size: BigInt): void;\n  read(): Uint8Array;\n  readString(): string;\n  write(buf: Uint8Array): number;\n  writeString(buf: string): number;\n  flush(): void;\n  seek(position: number): number;\n}\n```\n\n## Building\n\nTo build this library you will need to have installed in your system:\n\n* Node.JS\n* [Rust][Rust]\n* [wasm-pack][wasm-pack]\n* [wabt][wabt] (for `wasm-strip`)\n* [binaryen][binaryen] (for `wasm-opt`)\n\n```sh\nnpm i\nnpm run build\n```\n\n## Testing\n\nBuild the pkg and run the tests:\n\n```sh\nnpm run build\nnpm run test\n```\n\n# What is WebAssembly?\n\nQuoting [the WebAssembly site](https://webassembly.org/):\n\n> WebAssembly (abbreviated Wasm) is a binary instruction format for a\n> stack-based virtual machine. Wasm is designed as a portable target\n> for compilation of high-level languages like C/C++/Rust, enabling\n> deployment on the web for client and server applications.\n\nAbout speed:\n\n> WebAssembly aims to execute at native speed by taking advantage of\n> [common hardware\n> capabilities](https://webassembly.org/docs/portability/#assumptions-for-efficient-execution)\n> available on a wide range of platforms.\n\nAbout safety:\n\n> WebAssembly describes a memory-safe, sandboxed [execution\n> environment](https://webassembly.org/docs/semantics/#linear-memory) […].\n\n# License\n\nThe entire project is under the MIT License. Please read [the\n`LICENSE` file][license].\n\n[license]: https://github.com/wasmerio/wasmer/blob/master/LICENSE\n[Rust]: https://www.rust-lang.org/\n[wasm-pack]: https://rustwasm.github.io/wasm-pack/\n[wabt]: https://github.com/WebAssembly/wabt\n[binaryen]: https://github.com/WebAssembly/binaryen\n","publish_time":1662060029818,"_cnpm_publish_time":1662060029818,"dist-tags":{"latest":"1.2.2"}}