{"_id":"@dashbook/wasmer-wasi-js","_rev":"2-a38a8825dd985b9c290abb6b48e61261","name":"@dashbook/wasmer-wasi-js","dist-tags":{"latest":"1.2.4"},"versions":{"1.2.2":{"name":"@dashbook/wasmer-wasi-js","version":"1.2.2","module":"wasmer_wasi_js.js","types":"wasmer_wasi_js.d.ts","sideEffects":false,"dependencies":{"sync-idb-fs":"0.1.23"},"gitHead":"af39065dfa95ff562fd713516c51e3b93dc2f7ed","description":"This repository consists of multiple packages: * [Wasmer WASI](#wasmer-wasi)","_id":"@dashbook/wasmer-wasi-js@1.2.2","_nodeVersion":"19.8.1","_npmVersion":"8.19.2","dist":{"integrity":"sha512-EtJRi2mww6o7F1EjylZeNw1opd3jMyCAqDvZkvJXSC2Jol97cRIMaDyYLS/JZHGub7HwOzU8t1ajZDxr2Eemzg==","shasum":"bed6d7191a0d6b0d0a6992ed6ac35501e509af23","tarball":"https://registry.npmjs.org/@dashbook/wasmer-wasi-js/-/wasmer-wasi-js-1.2.2.tgz","fileCount":5,"unpackedSize":404193,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCcEnn6EssunHpfvaM0Ne+6fuS5BKFxX8HJB6uTzJrlhQIhAPU43FSZxp9IfA29ilxIuwCQt3OfbYQ+SgrgGvCPlRX3"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkLTm0ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrUAxAAnkoWx6XuwWv5MXgI2YjCvffsXKBzMFJ5NkLUuiL4z9H/oKNp\r\nITaQ4E1woJLTyEEpUV404uQpBnLUmhRA4Lx5SYdvFTWGebKs1js2Frl00rgZ\r\nw24suHC0wI5hEpbrnR+FtUVHI/8j3RWrHeruJGNdqRIX+glJCpIXzpdcG7Ih\r\nFGHE1P1/7ePzzM5SWTjFLJvT69yeYqWxZ2khX0AJMcuCmnqrxpVS3+WXJ62e\r\nnWuBBxLFNHOBdDbJCRfZpyzoQuQtgDrnazwzZFpD3fyn9+NocfGTaQWsayqV\r\nZASZJBrb3dQPqvr3as/HTul4p9mhZ4HWOdBlTSWM3x3ptqkI6TS/FlQ4qc3q\r\nQu1XOI19YmQkOUJhVmDhmAZsdkYqeyWJhVs43InGwQKNhqZih7P5Q8oNjbjF\r\nAIeBG2ffgQEl+gBr/IjhlF2mhF1gBWP/0sWce7MRr+uVCXhBzGQjGwJ6FzYy\r\nkUjAl5HEqT6BT1wqSB6fJ7w1rQez2lTzT22E3uRp+Av5ZSmge9cm71DeLHwn\r\nWlBsReA727Utiz9/P7WYzquvzW7/fhaLvB3UQzeVrCmIoZuSHQYedVMfRJS/\r\nbdFfTCppsCX08RbHCTgGq+S90uWeqKL5cjZdHffL3Nrd0FXHbDTXg/AVxaWV\r\nli3VH0dRCWJTTtNyIvCw8WXGg+073/5W7oI=\r\n=XJW8\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"dashbook","email":"jan_kaul@mailbox.org"},"directories":{},"maintainers":[{"name":"dashbook","email":"jan_kaul@mailbox.org"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/wasmer-wasi-js_1.2.2_1680685492030_0.9142281609004546"},"_hasShrinkwrap":false},"1.2.3":{"name":"@dashbook/wasmer-wasi-js","collaborators":["Syrus Akbary <syrus@wasmer.io>"],"version":"1.2.3","module":"wasmer_wasi_js.js","types":"wasmer_wasi_js.d.ts","sideEffects":false,"dependencies":{"sync-idb-fs":"0.1.23"},"gitHead":"af39065dfa95ff562fd713516c51e3b93dc2f7ed","description":"This repository consists of multiple packages: * [Wasmer WASI](#wasmer-wasi)","_id":"@dashbook/wasmer-wasi-js@1.2.3","_nodeVersion":"19.8.1","_npmVersion":"8.19.2","dist":{"integrity":"sha512-4AApMOEJGKwTKySBhfQYbj76jXKoKZCNFrhrCf6Uc4udkXtAu/1yCrLm+OI9C+ZkrnSYB20spsl5WTN3zkBAzg==","shasum":"d5065dd468d9e0dca863cd9db7fd6e58f407a880","tarball":"https://registry.npmjs.org/@dashbook/wasmer-wasi-js/-/wasmer-wasi-js-1.2.3.tgz","fileCount":6,"unpackedSize":396855,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCNg3NHfRVcl+2/b9tIcE9ZW2Y/ImrPtXAZaDBF80nWlgIgaNaxYZk7QgPCl3ORGiTeqwp5mazbv2Vy7xDQms8/Y3Q="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkLUYTACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrSRQ//X1JZLkzU5KPASOkgaadnSukU6x7oVS0WlDRKtXTtNbe4bBYZ\r\nZN+2gtdk23og1j9e4EGZdnEPItKbBIK3FS4nbd4ZUBI0iEI5lzC8b0jCMYIB\r\ndb67XB3fou60jqZdNhkUfAej/sGw4vkPVd71mqweNGWBl6p4Ohn+yeRzFeZK\r\nVB/qMKZd8ArqmQ8qA88x++85VssYbLzKnIDzJ3Yr55Dn4tl/wpoWGWNpzHqP\r\n2+BqST8575MuJmbrgmmLKI6XUJm69/K43B10C45d7otVRFd9SZFP6oqKcFfe\r\n+3XdryutZ9nUhsdEMnFofXaIxDPwgjEQSCufYYnhoaFxpwwHyNp5sK6piEhF\r\nGzmPpCe5r7RNpNPliw/Djhy4MGmrlSHECDpxL3TJNLUGfPUXtXxDX5nfVgoF\r\nZjatjLxspmZx9QebQWMlYDDNnbHdFU2e5G4Lv/GijfeOQWvOUBxDCijUAxNk\r\nG9DC3x5MlG6aOx0uT+ltGgTkf6RNOExm96YnSl0/D2PeTskMvOGgQl9Jc2E2\r\npfKh6okeVgh/h1D/uSC5qYC3Sbs2lHHQvQFyl5H4sJHjnrcbb1Sv3qwO+9xe\r\nxjQu+Cb2L8AAjB3vOl+5caKdCuQ86xdNB1s3irFnxG51H8jF719nPHPzDCFt\r\nOInAKvoJOskFWd5wVxDrfbCOGsTll3aHVzo=\r\n=MzjA\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"dashbook","email":"jan_kaul@mailbox.org"},"directories":{},"maintainers":[{"name":"dashbook","email":"jan_kaul@mailbox.org"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/wasmer-wasi-js_1.2.3_1680688659335_0.18765394848927452"},"_hasShrinkwrap":false},"1.2.4":{"name":"@dashbook/wasmer-wasi-js","collaborators":["Syrus Akbary <syrus@wasmer.io>"],"version":"1.2.4","module":"wasmer_wasi_js.js","types":"wasmer_wasi_js.d.ts","sideEffects":["./snippets/*"],"dependencies":{"sync-idb-fs":"0.1.23"},"_id":"@dashbook/wasmer-wasi-js@1.2.4","gitHead":"79627a3921456fff84645feaf713869e54f854d0","description":"This repository consists of multiple packages: * [Wasmer WASI](#wasmer-wasi)","_nodeVersion":"20.8.0","_npmVersion":"10.2.0","dist":{"integrity":"sha512-mSIQHRxbSL7m2Np8qUzZqxeq488n5BJKynYuITUcBOEKyCgbobeQkjfsR6dUcn3ttA5/gUgm/tYcUHw55bL2MA==","shasum":"ce5f3cbaaf6d57eb7d6af896cda2a2981c917948","tarball":"https://registry.npmjs.org/@dashbook/wasmer-wasi-js/-/wasmer-wasi-js-1.2.4.tgz","fileCount":5,"unpackedSize":390068,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDlrASryR0laQEhkV92x1kHNOaBP4MRF3dFjtu043xxpAiBwaZR9elfG81WGefKZC3CR94Mf8ZCQzHIv5s10ZCG2UA=="}]},"_npmUser":{"name":"dashbook","email":"jan_kaul@mailbox.org"},"directories":{},"maintainers":[{"name":"dashbook","email":"jan_kaul@mailbox.org"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/wasmer-wasi-js_1.2.4_1699299674584_0.17853831171189483"},"_hasShrinkwrap":false}},"time":{"created":"2023-04-05T09:04:51.980Z","1.2.2":"2023-04-05T09:04:52.350Z","modified":"2023-11-06T19:41:15.058Z","1.2.3":"2023-04-05T09:57:39.552Z","1.2.4":"2023-11-06T19:41:14.863Z"},"maintainers":[{"name":"dashbook","email":"jan_kaul@mailbox.org"}],"description":"This repository consists of multiple packages: * [Wasmer WASI](#wasmer-wasi)","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","readmeFilename":"README.md"}