# @wasmer/io-devices

> Isomorphic library to implement the experimental Wasmer I/O devices for wasmfs instances 🖼️🎮

Latest version **0.12.0** (published 2020-09-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install @wasmer/io-devices
pnpm add @wasmer/io-devices
yarn add @wasmer/io-devices
bun add @wasmer/io-devices
```

## Health

**Score 45/100 (D)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high maintenance score; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 0.12.0 |
| Published | 2020-09-16 |
| First published | 2020-01-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 25.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1268 |
| Author | Wasmer Engineering Team |
| Maintainers | syrusakbary |
| Keywords | wasm, wasi, fs, file, system, wapm, wasmer |

## Links

- npm: https://www.npmjs.com/package/@wasmer/io-devices
- Repository: https://github.com/wasmerio/wasmer-js
- Homepage: https://github.com/wasmerio/wasmer-js/tree/master/packages/io-devices
- Issues: https://github.com/wasmerio/wasmer-js/issues
- npm.io page: https://npm.io/package/@wasmer/io-devices

## Alternatives

- [unionfs](https://npm.io/package/unionfs.md) — 2.2M weekly downloads
- [path-starts-with](https://npm.io/package/path-starts-with.md) — 35.9K weekly downloads
- [redzip](https://npm.io/package/redzip.md) — 1.2K weekly downloads
- [vscode-anymatch](https://npm.io/package/vscode-anymatch.md) — 848 weekly downloads
- [@ledgerhq/coin-filecoin](https://npm.io/package/@ledgerhq/coin-filecoin.md) — 793 weekly downloads

## Recent versions

- 0.12.0 (latest) — 2020-09-16
- 0.11.2 — 2020-05-14
- 0.11.1 — 2020-05-14
- 0.11.0 — 2020-05-13
- 0.10.2 — 2020-03-18
- 0.10.1 — 2020-03-10
- 0.10.0 — 2020-03-05
- 0.9.1 — 2020-03-02
- 0.9.0 — 2020-02-29
- 0.8.5 — 2020-02-24
- 0.8.4 — 2020-02-22
- 0.8.3 — 2020-02-21
- 0.8.2 — 2020-02-21
- 0.8.1 — 2020-02-21
- 0.8.0 — 2020-02-21
- … 3 more at https://npm.io/package/@wasmer/io-devices/versions

## README

# `@wasmer/io-devices`

Isomorphic library to implement the experimental Wasmer I/O devices for the Wasmer-JS stack 🖼️🎮

Documentation for Wasmer-JS Stack can be found on the [Wasmer Docs](https://docs.wasmer.io/wasmer-js/wasmer-js).

## Table of Contents

- [Features](#features)
- [Installation](#installation)
- [Quick Start](#quick-start)
- [Documentation](#documentation)
- [Contributing](#contributing)

## Features

This package provides the following features:

- Scaffolds files used by the [Wasmer Runtime I/O Devices](https://docs.wasmer.io/runtime/runtime), to allow WASI moduels that depend on these interfaces to run in the browser and Node! 📁
- Allows reading the current RGBA FrameBuffer. 🖼️
- Can send input events to the I/O Devices interface. ⌨️

## Installation

For installing `@wasmer/io-devices`, just run this command in your shell:

```bash
npm install --save @wasmer/io-devices
```

## Quick Start

```js
import { WasmFs } from "@wasmer/wasmfs";
import { IoDevices } from "@wasmer/io-devices";

const wasmFs = new WasmFs();
const ioDevices = new IoDevices(wasmFs);

// Let's say we want to read the frame buffer,
// every time the buffer index display file is written to:
let callbackCalled = false;
const callback = () => {
  // Read the framebuffer
  console.log(ioDevices.getFrameBuffer); // Outputs a Uint8Array of the frame buffer

  callbackCalled = true;
};

// Set the callback, and write to the file to call it
ioDevices.setBufferIndexDisplayCallback(callback);
wasmFs.fs.writeFileSync("/_wasmer/dev/fb0/draw", "0");

callbackCalled === true; // This should be true, our callback is called!
```

`@wasmer/io-devices` is isomorphic, meaning this quick start should also work in Node with the appropriate Node syntax!

## Contributing

This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification.

Contributions of any kind are welcome! 👍

---
_Source: https://npm.io/package/@wasmer/io-devices · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
