Git Product home page Git Product logo

runno's Introduction

Runno WASI runtime

This is a simplified version of the @runno/wasi runtime.

This package allows you to run WASI binaries on the web with an emulated filesystem. If the binary receives calls to stdin/out/err then you get callbacks you'll need to handle. In future there may be other callbacks to intercept interesting system level events, or hooks into the filesystem.

Quickstart

The quickest way to get started with Runno is by using the WASI.start class method. It will set up everything you need and run the Wasm binary directly.

Be aware that this will run on the main thread, not inside a worker. So you will interrupt any interactive use of the browser until it completes.

<script src="https://unpkg.com/@antonz/runno/dist/runno.js"></script>
const { WASI } = window.Runno;

//...

const result = WASI.start(fetch("/binary.wasm"), {
    args: ["binary-name", "--do-something", "some-file.txt"],
    env: { SOME_KEY: "some value" },
    stdout: (out) => console.log("stdout", out),
    stderr: (err) => console.error("stderr", err),
    stdin: () => prompt("stdin:"),
    fs: {
        "/some-file.txt": {
            path: "/some-file.txt",
            timestamps: {
                access: new Date(),
                change: new Date(),
                modification: new Date(),
            },
            mode: "string",
            content: "Some content for the file.",
        },
    },
});

Note: The args should start with the name of the binary. Like when you run a terminal command, you write cat somefile the name of the binary is cat.

The filesystem

@runno/wasi internally emulates a unix-like filesystem (FS) from a flat structure. All files must start with a / to indicate they are in the root directory. The / directory is preopened by @runno/wasi for your WASI binary to use.

Paths provided to the FS can include directory names /like/this.png. The FS will treat files with the same prefix /like/so.png as if they are in the same folder. Any folders created will contain an empty .runno file /like/.runno as a placeholder.

WASI has a complex permissions system that is entirely ignored. All files you provide can be accessed by the WASI binary, with all permissions.

Which WASI standards are supported?

Currently @runno/wasi supports running only unstable and snapshot-preview1 WASI binaries. The snapshot-preview1 standard is more recent, and preferred. Additionally its likely some details of unstable have been missed. If you spot these, please file a bug.

Other extension standards like WASMEdge, and WASIX are currently not supported, but could be. WASI Modules are also not supported, but I'm interested in learning more about them.

License

Copyright 2023 Ben Taylor.

The software is available under the MIT license.

runno's People

Contributors

nalgeon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.