The Wayward Developer

WebAssembly Visual Server

WebAssembly modules cannot be referenced directly from HTML, instead additional JavaScript code is required to load, compile, and instantiate them. For security reasons, this also prevents them to be loaded directly from local disk, instead they have to be served over HTTP with the appropriate cross-origin header.

WebAssembly Visual Server is a small, cross-platform graphical utility that serves WebAssembly modules locally, eliminating the need to configure and run a full-featured web server for development. It can also open a page with the module already loaded, compiled, and instantiated, for easy access in the console.

Downloads

Contents

  1. Overview
    1. Running
    2. Endpoints
    3. Adding and editing
    4. Opening
    5. Updates
    6. Statistics
    7. Persistence
  2. Development
  3. Compilation
  4. License

Overview

Running

The application can be run directly, no installation is required.

Endpoints

The application maintains a list of endpoints consisting of an IP address and port number to listen on, a path to serve the module at, the file system path to read the module from, and a status indicating if the endpoint is enabled.

Once enabled, the module associated with the endpoint is accessible at any URL referencing the address in either numeric form or as a hostname resolving to it, the port, and path, with the content type application/wasm and the Access-Control-Allow-Origin header set to the value *.

Addresses and ports are held only as long as there’s an endpoint associated to them enabled. At start all endpoints are disabled, and at exit all enabled endpoints are disabled again.

The list of endpoints is displayed as a table with resizable columns. Buttons below allow adding new endpoints, and enabling, disabling, opening, editing, and removing the selected endpoint. Only enabled endpoints can be opened, and only disabled endpoints are allowed to be edited or removed.

Adding and editing

Adding and editing is done using the same dialog: in the latter case fields are prefilled with the edited values, in the former the file field is empty, while the address, port, and path fields are filled with defaults. Attempting to save with the file field empty results in an error. The address, port, and path fields, when invalid values are entered, revert them upon losing focus.

Adding endpoints to the list with addresses and ports held by other processes or conflicting paths will not result in an error until attempting to enable them.

Opening

Every endpoint has an associated page accessible by appending the query string ?! to its URL. When opened, this page loads, compiles, and if it requires no imports, instantiates the associated module. The module and if instantiated, the instance are available as the global objects module and instance. Any resulting errors are printed to the console.

The Open button opens the page using the system default browser. If opening in a browser fails, a dialog is displayed with the option to copy the URL to the clipboard.

Updates

Available updates are checked for at start and displayed in a dialog with options to visit the associated URL, dismiss it, or defer until next time. Checking for updates can be disabled with the -u command line flag.

Statistics

The application sends statistical information about usage and the system. Sending of statistical data can be disabled with the -s command line flag.

Persistence

The list of endpoints, the width of columns, the size, location, and maximization state of the window, and the list of updates already acted on are automatically saved on exit to a system-specific location and loaded next time.

If multiple instances of the application are run simultaneously, and the list is modified in any of the instances, the lists will get out of sync, and the last set of values saved will overwrite the others.

When given the -d command line flag, the application deletes all saved values and exits.

Development

The source code and issues are available at GitHub.

Compilation

To compile from source install Kotlin 1.3, JDK 11, Go 1.12, and Python 3.7, and then run the compile.py script from any directory:

./compile.py <executable path> <jdk path> <system> <architecture>

Instead of specifying them on the command line, arguments can also be given as environment variables. When both specified, command-line arguments are given priority over environment variables. A single - can be used in place of a command-line argument to only specify certain arguments on the command line.

<executable path> or the WAVS_EXECUTABLE_PATH environment variable is the path of the generated executable. It can be a path to either a file or a directory, in which case a default file name of webassembly-visual-server is used.

<jdk path> or the WAVS_JDK_PATH environment variable is the path to the directory containing the Java Development Kit the Java runtime packaged with the executable will be generated from.

<system> or the WAVS_SYSTEM environment variable and <architecture> or the WAVS_ARCHITECTURE environment variable are the target operating system and processor architecture identifiers passed to the Go compiler.

License

WebAssembly Visual Server is licensed under the ISC License.