wasd
0.6.2, released 8 days ago by medz.dev
Pure Dart WebAssembly runtime for executing Wasm modules, components, and WASI.
What it does
WASD provides a Dart-native WebAssembly runtime that decodes, validates, compiles, and instantiates WebAssembly modules and components directly in Dart and Flutter. It includes built-in host runners for WASI Preview1, Preview2, and Preview3 environments without needing native runtime dependencies in the core library.
AI-written summary of version 0.6.1, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need to run WebAssembly modules or components natively within a pure Dart or Flutter application.
- You want to execute WASI-compatible command or proxy components on the Dart VM.
- You need explicit host function imports, import maps, and typed wrappers for WebAssembly integration.
Skip it when
- You require full Core, Component Model, or WASI conformance where edge-case spec parity is critical.
- You are targeting platforms or scenarios with strict limitations on JIT or interpreter performance for heavy Wasm workloads.
Strengths
- Pure Dart core runtime with no external native library dependencies for the core library.
- Supports WASI Preview1, Preview2 (0.2.12), and Preview3 (0.3.0/0.3.1) command and service components.
- Provides WebAssembly-style operations like compile, instantiate, and validate with custom import maps.
Weaknesses
- Does not claim full Core, Component Model, or WASI conformance.
- Certain TCP bind and network capabilities are platform-dependent or return not-supported on non-Linux/macOS platforms.
Setup
- Kind
- FFI (native library)
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 1
Add the dependency to pubspec.yaml using pub add wasd.
import 'dart:typed_data';
import 'package:wasd/wasd.dart';
Future<void> main() async {
final Uint8List wasmBytes = loadYourModuleBytes();
final runtime = await WebAssembly.instantiate(wasmBytes.buffer);
final addExport = runtime.instance.exports['add'];
if (addExport is! FunctionImportExportValue) {
throw StateError('Expected `add` export to be a function.');
}
final result = (addExport.ref([20, 22]) as num).toInt();
print(result); // 42
}
Uint8List loadYourModuleBytes() => throw UnimplementedError();Alternatives
Packages that do the same job and could replace wasd.
- antlr4
Dart runtime libraries for ANTLR 4 parser generator.
50Compare - flutter_background_service_platform_interface
Platform interface for flutter_background_service plugin
50Compare - brotli
Pure Dart Brotli decoder
50Compare - wasm_interop
Dart wrapper for the WebAssembly JavaScript API.
41Compare
Works with
Packages commonly used together with wasd: ones it builds on, ones built on it, and its own family.