Component Model¶
Use component-model when plugin boundaries should be described with WIT and
lifted/lowered through the canonical ABI instead of ad-hoc JSON payloads.
The module provides:
- WIT parsing and package models,
- Kotlin binding generation for host and guest contracts,
- canonical ABI lowering and lifting,
WasmPluginfor loading core Wasm modules and component artifacts,- WASI Preview 2 host wiring,
- WASI Preview 3 canonical support,
- optional helpers for
wasm-tools component embed,component new, component unbundling, and validation.
The component-model runtime does not include wasm-tools.wasm. On JVM, add
uk.shusek.krwa:component-model-tooling when using the tooling-backed helpers,
WIT normalization, or WasmPlugin.builderFromComponent(...). The Component
Model Gradle plugin includes it automatically. Hosts that already have a parsed
WitPackage and a core WasmModule need only component-model:
WIT is the stable contract. Generated Kotlin should be treated as build output for hosts and guests that implement that contract.
Typical Flow¶
- Define the plugin world in WIT.
- Generate Kotlin contracts for the host and guest.
- Implement the host imports and guest exports.
- Package the guest core Wasm as a component when needed.
- Load the plugin with
WasmPluginand view exports through the generated Kotlin interface.
For Kotlin/Wasm guests, generated export adapters can expose WIT world
functions as @WasmExport wrappers so the component packager can discover the
core Wasm exports matching the contract.