Skip to content

Latest commit

 

History

History
200 lines (150 loc) · 5.45 KB

hold.mdx

File metadata and controls

200 lines (150 loc) · 5.45 KB
sidebar_position
2

import Link from '@docusaurus/Link';

Getting Started

import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import useIsBrowser from '@docusaurus/useIsBrowser';

The waPC suite gives you the tools to build dynamic applications with WebAssembly.

Learn More Download Chat

The WebAssembly Procedure Call project — waPC for short — is a suite of tools and specifications that allow native code to make, receive, and forward arbitrary calls to or from WebAssembly guests.

WaPC has host implementations for Rust, Go, Node.js, and browser environments and guest libraries for Rust, Go, and AssemblyScript.

Quickstart

export const os = () => { const isBrowser = useIsBrowser(); const platform = isBrowser ? navigator.platform : ''; if (platform.substring('Mac') != 1) { return "macos" } if (platform.substring('Linux') != 1) { return "linux" } return "windows" }

Step 1: Install the wapc CLI

> powershell -Command "iwr -useb https://raw.githubusercontent.com/wapc/cli/master/install/install.ps1 | iex"
$ curl -fsSL https://raw.githubusercontent.com/wapc/cli/master/install/install.sh | /bin/bash
$ wget -q https://raw.githubusercontent.com/wapc/cli/master/install/install.sh -O - | /bin/bash
$ brew install wapc/tap/wapc

Step 2: Generate a new project

$ wapc new assemblyscript hello_world_as
$ wapc new rust hello_world_rust
$ wapc new tinygo hello_world_tinygo
$ cd hello_world_tinygo
$ make codegen
$ go mod tidy

Step 3: Build

$ make
Copy

Step 4: Run

The waPC tool suite

The waPC protocol

The core of waPC is a protocol for communicating into and out of WebAssembly.

Use waPC for everything from small libraries to distributed application platforms.

waPC Hosts & Guests

waPC hosts manage the lifecycle and communication of WebAssembly guests.

Hosts and guests give you a universal interface for dynamic behavior in both native and WebAssembly.

Apex code generator

Use the [Apex Language](https://apexlang.io) to define your WebAssembly's specification and the `wapc` CLI to generate all the code except your business logic.

How it works

waPC Host
Once initialized with a WebAssembly intepreter and a wasm binary, the wapc-host library can start executing functions in the wasm guest. The host and guest operate over the waPC communication protocol to satisfy bindings for compiled languages. This protocol takes an operation name and input data, serializes it, and calls the receiving waPC method in the wasm guest.
waPC Guest
The wasm binary — built with the wapc-guest bindings — accepts the waPC call, deserializes the input, executes the requested operation by name, serializes the return value, and passes it back over the waPC protocol back to the host.
Apex
Your Apex definition is the description of your wasm module's interface. It includes the exposed operations, the input types, return types, namespaces, and more. The waPC CLI uses Apex definitions to generate Rust, Go, or AssemblyScript code. (see more)
waPC CLI
The waPC command line tool automates the process of creating new projects and generating waPC-compliant integration code.