π waclay
WebAssembly Component Layer - Runtime Agnostic
A maintained fork bringing the WebAssembly Component Model to life
Features β’ Quick Start β’ Examples β’ Contributing β’ Credits
π About This Project
waclay (WebAssembly Component Layer) is a runtime-agnostic implementation of the WebAssembly Component Model. This project enables you to load, link, and execute WASM components with full component model support across any WebAssembly runtime backend.
π― Why This Fork?
This is a maintained fork of the original wasm_component_layer project. After the original developer discontinued active maintenance, the project became difficult to compile and use with modern Rust toolchains. This fork aims to:
- β Keep it compiling - Updated to work with latest Rust and dependencies (50+ commits of fixes and improvements)
- β
Add new features - Including the new
wit-bindgen-wcltool for generating host bindings - β Maintain usability - Making it a practical tool for plugin development and WASM-based applications
- β Stay runtime agnostic - Preserving the brilliant design that works with Wasmi, Wasmtime, and other backends
- β Build community - Welcoming contributions to help maintain and improve the project
π‘ The Brilliant Design
The original author's vision of a runtime-agnostic component layer combined with the wasm_runtime_layer abstraction is truly innovative. This design allows you to:
- Switch between different WASM runtimes (Wasmi, Wasmtime, etc.) without changing your code
- Use the same Component Model API regardless of the underlying execution engine
- Build portable WASM applications that work across multiple platforms and backends
This architecture is essential for the WASM ecosystem as we wait for the Component Model to be finalized and fully supported across all runtimes.
β¨ Features
Core Capabilities
- π§ Component Model Support - Full implementation of WebAssembly Component Model
- π Runtime Agnostic - Works with Wasmi, Wasmtime, and any backend via
wasm_runtime_layer - π Type System - Complete support for WIT types: records, variants, enums, resources, etc.
- π Zero Unsafe Code - 100% safe Rust implementation
- π¦ Resource Management - Proper handling of owned and borrowed resources with destructors
- π Dynamic Loading - Runtime inspection and generation of component interface types
- β‘ Optimized Lists - Specialized list types for faster lifting/lowering operations
NEW: wit-bindgen-wcl
wit-bindgen-wcl is a command-line tool that generates ergonomic Rust host bindings from WIT files:
- β¨ Type-Safe Bindings - Generates strongly-typed Rust code from WIT definitions
- π― Easy Integration - Simple workflow from WIT β Rust bindings β Host application
- π§ Active Development - Basic features working for simple use cases (see examples)
- π€ Community Needed - Heavy development in progress, contributions welcome!
Current Status: Works for simple to moderate complexity WIT files. See the examples/ directory for supported patterns.
ποΈ Workspace Structure
This workspace contains two main crates:
waclay/
βββ crates/
β βββ waclay/ # π― Core Component Layer Library
β β βββ src/ # Runtime-agnostic component model implementation
β β βββ examples/ # 10 comprehensive examples showing features
β β βββ docs/ # API documentation and guides
β β
β βββ wit-bindgen-wcl/ # π§ WIT Binding Generator (NEW!)
β βββ src/ # Code generator for host bindings
β βββ examples/ # 9 examples with generated bindings
β
βββ test-waclay.ps1 # Test suite for core library
βββ test-wit-bindgen.ps1 # Test suite for binding generator
βββ test-all.ps1 # Complete workspace tests
π¦ Crates
waclay - Core Library
Runtime-agnostic WebAssembly Component Model implementation. Load and execute components on any WASM runtime!
- Version: 0.1.3
- License: Apache-2.0
- Repository: https://github.com/HemantKArya/waclay
wit-bindgen-wcl - Binding Generator
Generate type-safe Rust host bindings from WIT files. Makes working with components much more ergonomic!
- Status: Basic features working, contributions welcome
- Use Cases: Simple to moderate complexity WIT files (check examples)
- Community: Contributors needed to expand capabilities
π Quick Start
Prerequisites
# Install Rust (if not already installed)
|
# Install wasm-tools for building components
Installation
Installation
Option 1: Use in Your Project (Recommended)
Add to your Cargo.toml:
[]
= { = "https://github.com/HemantKArya/waclay" }
# Choose your runtime backend
= "0.51.0"
# OR
# wasmtime_runtime_layer = "21.0.0"
Note: Not yet published to crates.io - may be published in the future. Use git dependency for now.
Optional: Install wit-bindgen-wcl for generating bindings
If you want to generate host bindings from WIT files:
# Install the binding generator tool globally
# Now you can use it
Option 2: Build from Source
# Build the workspace
# Install the binding generator
Basic Usage Example
Basic Usage Example
Here's a simple example of loading and calling a WASM component:
1. Define your WIT interface (guest.wit)
1. Define your WIT interface (guest.wit)
package test:guest
interface foo {
// Selects the item in position n within list x
select-nth: func(x: list<string>, n: u32) -> string
}
world guest {
export foo
}
2. Load and call the component (Rust host code)
use *;
// The bytes of the component.
const WASM: & = include_bytes!;
That's it! You've successfully loaded and executed a WebAssembly component. π
Using wit-bindgen-wcl for Better Ergonomics
Generate type-safe bindings from WIT files:
# Generate bindings from WIT directory
# Use in your code
Then use the generated bindings for type-safe, ergonomic API:
use *; // Type-safe functions generated from WIT
// Much more ergonomic than raw Value manipulation!
π― How It Works
The Runtime Agnostic Architecture
βββββββββββββββββββββββββββββββββββββββββββββββ
β Your Application β
βββββββββββββββββββββββββββββββββββββββββββββββ€
β waclay (Component Layer) β
β β’ Component Model Implementation β
β β’ Type System & Lifting/Lowering β
β β’ Resource Management β
βββββββββββββββββββββββββββββββββββββββββββββββ€
β wasm_runtime_layer (Abstraction) β
β β’ Common Runtime Interface β
β β’ Backend Agnostic API β
ββββββββββββ¬βββββββββββ¬βββββββββββ¬βββββββββββββ€
β Wasmi β Wasmtime β Wasmer β Browser β
β Runtime β Runtime β Runtime β (JS) β
ββββββββββββ΄βββββββββββ΄βββββββββββ΄βββββββββββββ
Key Benefits:
- Write once, run anywhere - Your code works with any runtime
- Easy runtime switching - Change one line to switch backends
- Future-proof - As new runtimes emerge, they just work
- Testability - Test with lightweight runtime, deploy with optimized one
π€ Contributing
We need your help! This project is maintained and welcoming community contributions.
Why Contribute?
- π Shape the Future - Help build critical WebAssembly infrastructure
- π Learn WASM - Deep dive into Component Model internals
- π― Real Impact - Used in production for plugin systems and WASM applications
- π€ Welcoming Community - All skill levels welcome, we'll help you get started
What We Need
| Area | Priority | Description |
|---|---|---|
| π§ wit-bindgen-wcl | π΄ High | Expand binding generation for complex WIT patterns |
| π Documentation | π΄ High | API docs, tutorials, and guides |
| π§ͺ Testing | π‘ Medium | More comprehensive tests and edge cases |
| π Bug Fixes | π’ Ongoing | Report and fix issues |
| π‘ Features | π’ Ongoing | String transcoders, subtyping support |
| π¨ Examples | π’ Ongoing | More real-world use cases |
Getting Started
- Fork the repository
- Pick an issue or create a new one
- Make your changes with tests
- Submit a PR with a clear description
Check out existing examples and tests to understand the codebase. Don't hesitate to ask questions in issues!
Development Setup
# Clone your fork
# Run tests to ensure everything works
# Make your changes and test again
# ... your awesome contributions ...
πΊοΈ Roadmap
Current Focus (v0.1.x)
- Maintain compatibility with latest Rust
- Basic
wit-bindgen-wclfunctionality - Comprehensive documentation
- More
wit-bindgen-wclfeatures - String transcoder support
- Subtyping support
Future (v0.2.x+)
- Publish to crates.io
- Host binding macro (
#[derive(HostBindings)]) - Performance optimizations
- More runtime backend support
- WASI Preview 2 integration examples
Note: This project aims to bridge the gap until the Component Model is finalized by the WASI community and fully supported across all major runtimes. Community contributions are essential to keep it up-to-date.
π Examples
This repository includes 19 comprehensive examples demonstrating various features:
πΉ Core Library Examples (10 examples)
Using the raw component API - great for learning the fundamentals:
πΉ Core Library Examples (10 examples)
Using the raw component API - great for learning the fundamentals:
# From workspace root
πΈ Generated Bindings Examples (9 examples)
Using wit-bindgen-wcl for type-safe, ergonomic code:
# From workspace root
π‘ Tip: Examples prefixed with
bindgen-use generated bindings (more ergonomic), while others use the raw API (more flexible).
Building Your Own Components
Want to build the example components yourself?
# Navigate to any component example
# Install nightly toolchain
# Build the WASM module
# Convert to component
π§ͺ Testing
Comprehensive test suite with cross-platform support:
# π Quick tests (recommended for development)
# π Full test suite (all platforms)
# π― Test specific crate
# βοΈ Advanced options
Test Coverage:
- β Unit tests and integration tests
- β All 19 examples build and run
- β Cross-platform compatibility (Windows, Linux, Android)
- β Multiple runtime backends
βοΈ Optional Features
serde- Enable serialization for types and values (resources excluded as they're instance-bound)
= { = "https://github.com/HemantKArya/waclay", = ["serde"] }
π Supported Capabilities
β Fully Supported
- β Component parsing and instantiation
- β All WIT types (records, variants, enums, options, results, etc.)
- β Specialized list types for performance
- β Structural type equality
- β Guest resources
- β Host resources with destructors
- β Runtime type inspection
- β Multiple runtime backends
π§ In Progress
- π§
wit-bindgen-wcl- Basic features working, expanding coverage - π§ Comprehensive testing suite
- π§ Documentation and tutorials
π Planned
- π String transcoders
- π Host binding macros
- π Subtyping support
- π Performance benchmarks
π License
Licensed under the Apache License, Version 2.0. See LICENSE for details.
π Credits
Original Author
Huge thanks to DouglasDwyer for creating the original wasm_component_layer project. The core architecture and design are his brilliant work:
- π‘ Visionary Design - The runtime-agnostic component layer concept
- ποΈ Solid Foundation - Clean, well-structured codebase
- π§ wasm_runtime_layer - The abstraction that makes it all possible
Without this foundation, this project wouldn't exist.
This Fork
Maintained by HemantKArya since the original project was discontinued:
- π Trying to keep it compiling with modern Rust
- β¨ New
wit-bindgen-wcltool - π Improved documentation
- π€ Community building
Built With
This project stands on the shoulders of giants:
- wasmtime - Component Model implementation reference
- wit-parser - WIT parsing and validation
- wasm_runtime_layer - Runtime abstraction
- All the runtime backends: Wasmi, Wasmtime, and others
π Get in Touch
- π Found a bug? Open an issue
- π‘ Have an idea? Start a discussion
- π€ Want to contribute? Check our Contributing section
- β Like the project? Give us a star on GitHub!
Built with β€οΈ for the WebAssembly community
Making Component Model accessible to everyone, one runtime at a time