Kotlin Multiplatform WebAssembly Plugin Framework · Cross-Platform WASI Execution Runtime
中文文档 · English · Documentation
Wasmline is a Kotlin Multiplatform framework for loading and calling WASI-compliant WebAssembly plugins in Android, iOS, Desktop, and Web applications.
Define the service contract (commonMain):
// shared/src/commonMain/kotlin/com/example/EchoService.kt
import crow.wasmline.WasmlineService
interface EchoService : WasmlineService {
fun echo(message: String): String
}Register the implementation in the plugin (wasmWasiMain):
// plugin/src/wasmWasiMain/kotlin/Main.kt
import crow.wasmline.Wasmline
import crow.wasmline.bind
fun main() {
Wasmline.current.bind(object : EchoService {
override fun echo(message: String): String {
return "Response from WASI plugin: $message"
}
})
}Load the plugin and invoke services from the host:
import crow.wasmline.WasmlineConfig
import crow.wasmline.WasmlineLoadResult
import crow.wasmline.link
import crow.wasmline.loader.WasmlineLoader
import crow.wasmline.network.ktor.KtorNetworkClient
WasmlineLoader.bootstrap()
// Local paths and remote URLs are both supported — http(s):// loads the remote manifest
val module = when (val result = WasmlineLoader.load(
source = "https://example.com/plugin/manifest.wlm",
config = WasmlineConfig(networkClient = KtorNetworkClient()),
)) {
is WasmlineLoadResult.Success -> result.wasmline
is WasmlineLoadResult.Failure -> error(result.cause)
}
val response = module.link<EchoService>().echo("ping")
module.close()Note
link<T>() and bind(impl) are rewrite targets of the Kotlin IR compiler plugin. If wasmline-kotlin-plugin is not applied to the compilation unit, these calls throw UnsupportedOperationException at runtime.
| Platform | Architecture | Artifact Support | Loading |
|---|---|---|---|
| Android | v8a, x86_64 | .cwasm / .pwasm |
wasmtime |
| Android | v7a, x86 | .pwasm only |
wasmtime |
| iOS | arm64 | .pwasm |
wasmtime |
| macOS | arm64 | .cwasm / .pwasm |
wasmtime |
| Linux | x86_64 | .cwasm / .pwasm |
wasmtime |
| Windows | x86_64 | .cwasm / .pwasm |
wasmtime |
| Web (Kotlin/JS · Kotlin/WasmJS) | Browser JS engine | Raw .wasm only |
web |
Note
Wasmline is under active development. Detailed installation and integration documentation will be available at wuya.click/wasmline.
Wasmline is distributed under the Apache License, Version 2.0. See LICENSE for the complete license text.





