npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@wasmer/io-devices-lib-assemblyscript

v0.1.3

Published

Library for interacting with the Wasmer Experimental IO Devices in AssemblyScript

Downloads

11

Readme

io-devices-lib AssemblyScript

AssemblyScript library for building applications using the Wasmer Experimental IO Devices. 🔌

Features

  • Supports the Wasmer Framebuffers, so you can use WASI Modules to draw graphics! 🖼️
  • Supports Keyboard and Mouse Input APIs, so you can retrieve and use Input! ⌨️🐭

Installation

You can install io-devices-lib-assemblyscript in your project by running the following:

npm install @wasmer/io-devices-lib-assemblyscript

Quick Start

Here is an annotated snipped on displaying a static frame with the library. We recommend using as-wasi as well:

// Import some common functions from io-devices-lib-assemblyscript
import {
  isIoDevicesEnabled,
  openFrameBufferWindow, 
  closeFrameBufferWindow, 
  drawRgbaArrayToFrameBuffer, 
} from "../lib/lib";

// Import some useful utilities from as-wasi
import {Console, Time} from "as-wasi";

// Entry point into WASI Module
export function _start(): void {

  // Check if IO Devices is enabled, and throw an error if so.
  isIoDevicesEnabled(true);

  // Open a framebuffer that is 400 pixels wide, and 400 pixels tall, and use fb0
  openFrameBufferWindow(400, 400, 0);

  // Loop infinitely to keep the program running
  while(true) {

    // Create an one dimensional, Uint8 array for storing our RGBA information
    let rgbaFrame: Array<u8> = new Array<u8>();

    // Fill the rgbaFrame with a solid green color
    for (let x = 0; x < 400; x++) {
      for (let y = 0; y < 400; y++) {

        // Get which pixel we currently are at
        let pixelIndex = ((y * 400) + x) * 4;

        // Set our Red
        rgbaFrame[pixelIndex + 0] = 0;
        // Set our Blue
        rgbaFrame[pixelIndex + 0] = 0;
        // Set our Green
        rgbaFrame[pixelIndex + 0] = 255;
        // Set our Alpha
        rgbaFrame[pixelIndex + 0] = 255;
      }
    }

    // Draw the rgbaFrame to fb0
    drawRgbaArrayToFrameBuffer(rgbaFrame, 0);

    // Sleep approximately 16 milliseconds. 
    // This will make our loop run at 60 fps.
    Time.sleep(16 * Time.MILLISECOND);
  }
}

Usage of other features of the library, such as input support, can be found at the documentation. 📚