Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,16 @@ jobs:
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Publish assemblyscript-plugin-sdk
run: |
LOCAL_VERSION=$(awk '/"version":/{gsub(/("|",)/,"",$2);print $2}' packages/assemblyscript-plugin-sdk/package.json)
if ! npm view @signalk/assemblyscript-plugin-sdk@$LOCAL_VERSION version &>/dev/null; then
cd packages/assemblyscript-plugin-sdk
npm publish --access public
fi
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Set tag variable
id: vars
run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
Expand Down
18 changes: 18 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,21 @@ test/server-test-config/ssl-key.pem
test/server-test-config/plugin-config-data/

docs/built

# WASM build artifacts
*.wasm

# .net builds
jco-output/
obj/
bin/
Debug/
Release/
*.ps1
nul

# wasmtime build artifacts
*.wasm

# debug artefacts
*.sln
19 changes: 19 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ compilation-stats.json
.babelrc
public/*.hot-update.js
public/*.hot-update.json
**/stats.json
**/*.js.map

plugin-config-data/

Expand Down Expand Up @@ -77,3 +79,20 @@ fly_io

/docs/*
!/docs/dist


# .net builds
jco-output/
obj/
bin/
Debug/
Release/
*.ps1
nul

# wasmtime build artifacts
*.wasm

# debug artefacts
*.sln

5 changes: 5 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,8 @@ public

**/*.mbtiles
**/*.pmtiles
# AssemblyScript files use decorators that prettier doesn't understand
Comment thread
tkurki marked this conversation as resolved.
examples/wasm-plugins/*/assembly
packages/assemblyscript-plugin-sdk/assembly
# AssemblyScript build outputs
packages/assemblyscript-plugin-sdk/build
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,10 @@ To enable debugging without going through the Admin UI, see the file `~/.signalk

## Development

The documents provide more details about developing Webapps or Plugings for Signal K Server, as well as working on the server itself:
The documents provide more details about developing Webapps or Plugins for Signal K Server, as well as working on the server itself:

- [Contributing to this repo](./contributing.md)
- [Server Plugins](docs/develop/plugins/README.md)
- [Contributing to this repo](docs/develop/contributing.md)
Comment thread
dirkwa marked this conversation as resolved.
- [WASM Plugins](docs/develop/plugins/wasm/README.md) (Rust, AssemblyScript, Go)
- [Webapps](docs/develop/webapps.md)
- [Working with the Course API](docs/develop/rest-api/course_api.md)
- [Working with the Resources API](docs/develop/rest-api/resources_api.md)
Expand Down
12 changes: 12 additions & 0 deletions docs/develop/plugins/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
title: Plugins
children:
- ../webapps.md
- wasm/README.md
- deltas.md
- configuration.md
- backpressure.md
Expand All @@ -20,6 +21,17 @@ They are installed via the AppStore and configured via the Admin UI.

Signal K server exposes an interface for plugins to use in order to interact with the full data model, emit delta messages and process requests.

## Plugin Types

Signal K supports two types of plugins:

- **JavaScript Plugins** - Traditional JavaScript/TypeScript plugins (documented below)
- **[WASM Plugins](./wasm/README.md)** - Plugins written in Rust, AssemblyScript, Go, or other WASM-compatible languages

[WASM](https://en.wikipedia.org/wiki/WebAssembly) is short for WebAssembly. WASM is a runtime for executing portable code in near native speeds and in isolation. WASM plugins offer sandbox isolation, memory safety, and the ability to use languages other than JavaScript. See the [WASM Plugins documentation](./wasm/README.md) for details.

## Node.js Plugin Capabilities

Plugins can:

- Expose _[REST APIs](../rest-api/README.md)_ to provide consumers/clients a way to perform operations offered by your plugin. The APIs will be published under `http://{skserver}:3000/plugins/{pluginId}`.
Expand Down
155 changes: 155 additions & 0 deletions docs/develop/plugins/wasm/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
---
title: WASM Plugins
children:
- assemblyscript.md
- rust.md
- go.md
- dotnet.md
- http_endpoints.md
- deltas.md
- capabilities.md
- best_practices.md
- integration_guide.md
---

# WASM Plugin Development Guide

## Overview

This guide covers how to develop WASM/WASIX plugins for Signal K Server 3.0. WASM plugins run in a secure sandbox with isolated storage and capability-based permissions.

## What Makes a WASM Plugin?

A WASM plugin is an npm package that contains the WASM code for the plugin instead of the traditional JavaScript code. A WASM plugin is identified by the `signalk-wasm-plugin` keyword in package.json and the **`wasmManifest`** field in `package.json`:

```json
{
"name": "my-plugin-name",
"wasmManifest": "plugin.wasm",
"wasmCapabilities": { ... }
}
```

**Key points:**

- **`wasmManifest`** (required): Path to the compiled `.wasm` file. This field tells Signal K to load this as a WASM plugin instead of a Node.js plugin.
- **`wasmCapabilities`** (required): Declares what permissions the plugin needs (network, storage, etc.)
- **Package name** (flexible): Can be anything - `my-plugin`, `@myorg/my-plugin`, etc. There is **no requirement** to use `@signalk/` scope.
- **Keywords**: Include `signalk-wasm-plugin` for discovery (do **not** use `signalk-node-server-plugin` - that's for Node.js plugins only)

## Language Options

Signal K Server supports multiple languages for WASM plugin development:

- **AssemblyScript** - TypeScript-like syntax, easiest for JS/TS developers, smallest binaries (3-10 KB)
- **Rust** - Best performance and tooling, medium binaries (50-200 KB)
- **Go/TinyGo** - Go via TinyGo compiler, medium binaries (50-150 KB)
- **C#/.NET** - **NOT WORKING** - .NET 10 with componentize-dotnet produces WASI Component Model (P2/P3) format. Currently incompatible with Node.js/jco runtime. See [Creating C#/.NET Plugins](./dotnet.md) for details.

## Why WASM Plugins?

### Benefits

- **Security**: Sandboxed execution with no access to host system
- **Hot-reload**: Update plugins without server restart
- **Multi-language**: Write plugins in Rust, AssemblyScript, and more
- **Crash isolation**: Plugin crashes don't affect server
- **Performance**: Near-native performance with WASM
Comment thread
dirkwa marked this conversation as resolved.
- **Self contained**: WASM plugins do not install any additional dependencies
- **Small binaries (compared to native options)**: 3-200 KB depending on language

### Current Capabilities

- **Delta Emission**: Send SignalK deltas to update vessel data
- **Status & Error Reporting**: Set plugin status and error messages
- **Configuration**: The same JSON schema-based configuration as JS plugins
- **Data Storage**: VFS-isolated file storage
- **HTTP Endpoints**: Register custom REST API endpoints
- **Static Files**: Serve web UI from `public/` directory
- **Network Access**: HTTP requests via as-fetch (AssemblyScript)
- **Resource Providers**: Serve SignalK resources
- **Weather Providers**: Integrate with Signal K Weather API
- **Radar Providers**: Integrate with Signal K Radar API

## Choose Your Language

### AssemblyScript - Recommended for JS/TS Developers

**Best for:**

- Quick prototypes
- Simple data processing
- Migrating existing Node.js plugins
- Developers familiar with TypeScript

**Pros:**

- TypeScript-like syntax
- Fast development
- Smallest binaries (3-10 KB)
- Familiar tooling (npm)

**Cons:**

- Smaller ecosystem than Rust
- Some TypeScript features unavailable
- Manual memory management

**[Jump to AssemblyScript Guide](./assemblyscript.md)**

### Rust - Recommended for Performance-Critical Plugins

**Best for:**

- Performance-critical plugins
- Complex algorithms
- Low-level operations
- Production plugins

**Pros:**

- Best performance
- Memory safety
- Rich ecosystem
- Strong typing

**Cons:**

- Steeper learning curve
- Longer compile times
- Larger binaries (50-200 KB)

**[Jump to Rust Guide](./rust.md)**

### Go/TinyGo - For Go Developers

**Best for:**

- Go developers wanting to write plugins
- Medium complexity plugins
- Resource providers with hybrid patterns

**Pros:**

- Familiar Go syntax
- Good standard library support
- Medium binaries (50-150 KB)
- Strong typing

**Cons:**

- Requires TinyGo (not standard Go)
- Some Go features unavailable
- Slower than Rust

**[Jump to Go/TinyGo Guide](./go.md)**

### C#/.NET - NOT CURRENTLY WORKING

> **Status: Non-functional** - See [jco issue #1173](https://github.com/bytecodealliance/jco/issues/1173) for details and updates.

componentize-dotnet produces WASI Component Model format which is currently incompatible with the Node.js/jco runtime used by Signal K.

**Recommendation:** Use AssemblyScript or Rust instead.

**[Jump to C#/.NET Guide](./dotnet.md)** (reference only)
Loading