0.12.0 • Published 4 years ago

@wasmer/io-devices v0.12.0

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

@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.

Table of Contents

Features

This package provides the following features:

  • Scaffolds files used by the Wasmer Runtime I/O Devices, 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:

npm install --save @wasmer/io-devices

Quick Start

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 specification.

Contributions of any kind are welcome! 👍

0.12.0

4 years ago

0.11.2

4 years ago

0.11.0

4 years ago

0.11.1

4 years ago

0.10.2

4 years ago

0.10.1

4 years ago

0.10.0

4 years ago

0.9.1

4 years ago

0.9.0

4 years ago

0.8.5

4 years ago

0.8.4

4 years ago

0.8.1

4 years ago

0.8.3

4 years ago

0.8.2

4 years ago

0.8.0

4 years ago

0.7.1

4 years ago

0.7.0

4 years ago

0.6.0

4 years ago