{"name":"@wasmer/wasi","version":"0.4.2","keywords":["wasi","webassembly","wasm","wasmer","abi","esm","es","module"],"author":{"name":"Wasmer Engineering Team","email":"engineering@wasmer.io"},"license":"MIT","_id":"@wasmer/wasi@0.4.2","maintainers":[{"name":"syrusakbary","email":"me@syrusakbary.com"},{"name":"torch2424","email":"aaron@aaronthedev.com"}],"homepage":"https://github.com/wasmerio/wasmer-js/tree/master/packages/wasi","bugs":{"url":"https://github.com/wasmerio/wasmer-js/issues"},"dist":{"shasum":"cf590bc7927db482426053623e06e9d8bc009461","tarball":"http://registry-npm.ywwl.com/@wasmer/wasi/download/@wasmer/wasi-0.4.2.tgz","fileCount":37,"integrity":"sha512-DLlNK/ogU2xA5F5XTgBD9QA0zFwPT/KsXkylf8CgjfsPpYkvbYoVCVplrjjVYhn8v4lC0kGO2Dr647V/oHYUbA==","signatures":[{"sig":"MEUCIGg8FK0VNu/9CxaAN3BeeEMw5hi74IVddJQWpnPHgxbzAiEA0D9uXo+KnMN3nm9bjceC4DSf2oAQfkchVshQ8CkayDY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":268360,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdu4UbCRA9TVsSAnZWagAANgAP/imBI/V+mBAo9mK60KK0\nzD5BUlk9censzx8aYKEes/99G/Q8WO9VwkhsyFWFCiM0Gm+8ty/JmCvakm7r\nbxdJCr6p6enNha1haQ4T0K/eVs576eD5Xvxxd+PGtJzoHPBfbyNj2zqZszip\nDG3n0FN8yRuwFz4vxvKc0g2KBLs0U0y6pjO7/kCvzJ8kDh+0e5PGOOD8gQbW\nXUEWghngghXl+5eqwurUfcd2lniZ3JP2o08YN2LF6fBeAIYJ5Qypk7g5U7Vp\n/6Xh+cqGDpS+sjK4mUpFKQkYArIDkuHGykv+E6NCc149DqFRMdly22BKrP2m\n5RQEP4Ll12by7jUFvIAYOGlmSjnFKjQmna+p15p8Pjh4TllqWoHhSlPstDtP\nYiFaiVbmuYpwvOexC0gcrmwGLDN2sii3O6AxARK+mRywP1ejgK9IpHf+I0e9\nQX7uQgw+eyh9jdCwNR+maEIjRXPVNtM1WlJ19dr/VauitRbxNsEmlqM25syA\nGTEIC4a8Zs6UcYpHJCwMXZ4l6lkur2dQpA2XgAoR7QCzb9MGA/vtS/zIun7U\nOEQKlqVgsdW40IjiC6DtejHzafcOYGal326kAk6/HZuqB9M10LPXAHEVqdIm\nO3teMJR9ZVCao1DYLB44TRaaisQXr6fCkYP/nLJJ1sR4eV8l9BmiR9ifKHGD\nlT8c\r\n=xtkO\r\n-----END PGP SIGNATURE-----\r\n","size":60809,"noattachment":false,"key":"/@wasmer/wasi/-/@wasmer/wasi-0.4.2.tgz"},"main":"lib/index.cjs.js","module":"lib/index.esm.js","browser":"lib/index.iife.js","gitHead":"d61fbc6e997283a632887d90b0f9ea900fd0e7a3","scripts":{"dev":"npx watch \"npm run build:dev\" src","docs":"npx typedoc src/ --out docs --target es6 --theme minimal --mode file","test":"npx jest --config jest.config.js","build":"npx run-s build:clean build:ts build:prod","build:ts":"tsc -b","build:dev":"npx rollup -c --environment DEV","build:prod":"npx rollup -c --environment PROD","precompile":"cd test/rs && make all","test:watch":"npx jest --config jest.config.js --watch","build:clean":"rm -rf lib"},"typings":"lib/wasi/src/index.d.ts","_npmUser":{"name":"syrusakbary","email":"me@syrusakbary.com"},"repository":{"url":"git+https://github.com/wasmerio/wasmer-js.git","type":"git"},"_npmVersion":"lerna/3.18.3/node@v12.6.0+x64 (darwin)","description":"Isomorphic Javascript library for interacting with WASI Modules in Node.js and the Browser. 📚","directories":{},"_nodeVersion":"12.6.0","dependencies":{"buffer-es6":"^4.9.3","randomfill":"^1.0.4","path-browserify":"^1.0.0","browser-process-hrtime":"^1.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tslint":"^5.20.0","ts-node":"^8.4.1","typescript":"^3.6.4","npm-run-all":"^4.1.5","tslint-config-prettier":"^1.18.0"},"_npmOperationalInternal":{"tmp":"tmp/wasi_0.4.2_1572570394405_0.8216241901647414","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":1572570394569,"_cnpm_publish_time":1572570394569,"dist-tags":{"latest":"1.2.2"}}