WACS.ComponentModel
0.7.1
dotnet add package WACS.ComponentModel --version 0.7.1
NuGet\Install-Package WACS.ComponentModel -Version 0.7.1
<PackageReference Include="WACS.ComponentModel" Version="0.7.1" />
<PackageVersion Include="WACS.ComponentModel" Version="0.7.1" />
<PackageReference Include="WACS.ComponentModel" />
paket add WACS.ComponentModel --version 0.7.1
#r "nuget: WACS.ComponentModel, 0.7.1"
#:package WACS.ComponentModel@0.7.1
#addin nuget:?package=WACS.ComponentModel&version=0.7.1
#tool nuget:?package=WACS.ComponentModel&version=0.7.1
WACS.ComponentModel
WebAssembly Component Model runtime for WACS — WIT parsing, canonical-ABI lift/lower, resource handles, and component instantiation. Layered on the same parse / validate / link pipeline WACS uses for core modules; works with both the interpreter and the AOT transpiler engines.
What's inside
- Component runtime —
ComponentInstance.Instantiate, resource registries, variant / option / result / list / record / tuple / flags lift+lower - Canonical ABI — full lift/lower including aggregate returns through retArea, UTF-8 / UTF-16 / Latin-1 string encodings, recursive variant arms, instance-method resource calls
- WIT parser — vendored upstream grammar,
WitLoaderresolvesusechains across packages, embedded WIT files in assemblies viaWitContract.FromAssembly ComponentBridge— cross-engine adapter that lets interpreted and transpiled components compose against the same typed contractLinker.Validate(WitContract)— link-time check that bound host implementations match the WIT contract (catches drift before the component runs)
Install
dotnet add package WACS.ComponentModel
Quick start
using Wacs.ComponentModel.Runtime;
var bytes = File.ReadAllBytes("hello.component.wasm");
var ci = ComponentInstance.Instantiate(bytes,
rt =>
{
// configure host bindings on the underlying WasmRuntime
// — `--bind` shims, WASI Preview 2 hosts, custom IBindables
});
var result = ci.Invoke("greet", new object?[] { "world" });
Console.WriteLine(result);
For the WASI Preview 2 host implementations (cli / clocks / filesystem / http / io /
random / sockets), pair this package with WACS.WASI.Preview2
or WACS.WASI.Preview2.DependencyInjection.
For programmatic WIT ↔ C# binding generation, see
WACS.ComponentModel.Bindgen.Lib.
Engines
This package handles the component-model layer; the underlying core wasm executes through either:
- Interpreter (
WACS) — AOT-safe, ~270–385 iter/s on CoreMark, suitable for Unity IL2CPP /PublishAot. - Transpiler (
WACS.Transpiler.Lib) —Reflection.EmitAOT, ~17 500 iter/s on CoreMark, ~50% of native C speed.
The wacs run --wasip2 CLI verb auto-routes to the transpiler engine when WASI Preview 2
host packages are wired. See the top-level
WACS README for the full
matrix.
Documentation
docs/COMPONENT_CHAINING.md— runtime requirements, host-package composition, end-to-end CLI / embedder examplesWacs.ComponentModel/Validation/README.md— WIT contract validation deep-dive
License
Apache-2.0
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 is compatible. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- WACS (>= 0.15.22)
- WACS.ComponentModel.Parser (>= 0.1.0)
-
net8.0
- WACS (>= 0.15.22)
- WACS.ComponentModel.Parser (>= 0.1.0)
NuGet packages (9)
Showing the top 5 NuGet packages that depend on WACS.ComponentModel:
| Package | Downloads |
|---|---|
|
WACS.WASI.NN
WASI-NN host bindings for WACS — wasi:nn@0.2.0-rc-2024-10-28 (component-model WIT) plus the legacy wasi_ephemeral_nn (WITX) ABI. Backend-agnostic core; pluggable backends (ML.NET, ONNX Runtime, ONNX Runtime GenAI, LlamaSharp, TorchSharp, OpenVINO) ship as sibling packages. Tracks the wasi-nn proposal at WASI Phase 2 — the WIT surface may change as the proposal evolves. |
|
|
WACS.Transpiler.Lib
Library API for WACS.Transpiler — programmatic ahead-of-time WebAssembly-to-.NET IL transpilation, plus seamless loading of saved transpiled assemblies. v0.7.2 fixes a re-instantiation bug where Module classes with active data segments would come up zeroed on the second `Activator.CreateInstance` because spec §4.5.4 segment-drop emptied the process-wide ModuleInit registry. Module ctors now restore from `ModuleInitData.SavedDataSegments` before each CopyDataSegment so every fresh instance sees its memory initialized. v0.7 retires Lokad.ILPack for PersistedAssemblyBuilder (.NET 9), moves WASM data segments + the codec blob to RVA-mapped initialized data (62.5% smaller than the prior base64-in-#US path, true zero-copy from PE pages to ModuleInitData via UnmanagedMemoryStream), and introduces EmissionTarget.Auto as the new default — promotes to AotLinked when the module fits a conservative envelope (compute / memory / globals / tables + active+passive segments / multi-memory / local tags / imported functions), falling back to Standard otherwise. ~50% first-trial cold-start cut on promoted modules. ImportDispatcher now throws on missing handlers by default (lenient: true opts out). v0.6 consumed the Branch Hinting proposal's metadata.code.branch_hint custom section. v0.5 added the AotLinked emission target, stable AssemblyName, and the [WacsTranspiledImports] / [WacsImportNames] emission used by WACS.HostBindings.SourceGen. |
|
|
WACS.WASI.Preview2.DependencyInjection
Microsoft.Extensions.DependencyInjection extension methods for WACS.WASI.Preview2. Registers default host implementations + bindings + a pre-wired Linker. |
|
|
WACS.WASI.Preview2
WASI Preview 2 (component-model) host implementations for WACS |
|
|
WACS.WASI.NN.DependencyInjection
Microsoft.Extensions.DependencyInjection extension methods for WACS.WASI.NN. Registers the WasiNNBundle that the transpiler's HostPackageResolver direct-links wasi:nn imports against — symmetric with WACS.WASI.Preview2.DependencyInjection. |
GitHub repositories
This package is not used by any popular GitHub repositories.