diff --git a/component-model/book.toml b/component-model/book.toml index 74f0eaf2..bc2d8be5 100644 --- a/component-model/book.toml +++ b/component-model/book.toml @@ -8,7 +8,8 @@ title = "The WebAssembly Component Model" [output.html] git-repository-url = "https://github.com/bytecodealliance/component-docs/tree/main/component-model" edit-url-template = "https://github.com/bytecodealliance/component-docs/tree/main/component-model/{path}" -additional-css = ["theme/head.hbs"] +additional-css = ["theme/head.hbs", "theme/tabs.css", "theme/tabs-overrides.css", "theme/version-notice.css"] +additional-js = ["theme/tabs.js", "theme/tabs-url-sync.js", "theme/tabs-a11y.js"] [output.html.fold] enable = true @@ -34,4 +35,6 @@ level = 1 [preprocessor.alerts] +[preprocessor.tabs] + [output.linkcheck] diff --git a/component-model/src/running-components/wasmtime.md b/component-model/src/running-components/wasmtime.md index 4272725c..79bb781d 100644 --- a/component-model/src/running-components/wasmtime.md +++ b/component-model/src/running-components/wasmtime.md @@ -1,9 +1,25 @@ # Wasmtime +
+ +This page has content for both **WASI P2** and **WASI P3**. Use the tabs below to switch between versions where they differ. + +
+ +{{#tabs global="wasi-version" }} +{{#tab name="WASI P2" }} [Wasmtime](https://github.com/bytecodealliance/wasmtime/) is the reference implementation of the Component Model. -It supports running components that implement the [`wasi:cli/command` world](https://github.com/WebAssembly/wasi-cli/blob/main/wit/command.wit) -and serving components that implement the [`wasi:http/proxy` world](https://github.com/WebAssembly/wasi-http/blob/main/wit/proxy.wit). +It supports running components that implement the [`wasi:cli/command` world](https://github.com/WebAssembly/WASI/blob/main/proposals/cli/wit/command.wit) +and serving components that implement the [`wasi:http/proxy` world](https://github.com/WebAssembly/WASI/blob/main/proposals/http/wit/proxy.wit). Wasmtime can also invoke functions exported from a component. +{{#endtab }} +{{#tab name="WASI P3" }} +[Wasmtime](https://github.com/bytecodealliance/wasmtime/) is the reference implementation of the Component Model. WASI P3 runtime support is available in Wasmtime 43 and later, which implements the WASI 0.3 ABI (`async func`, `stream`, `future`). + +It supports running components that implement the [`wasi:cli/command` world](https://github.com/WebAssembly/WASI/blob/main/proposals/cli/wit-0.3.0-draft/command.wit). Support for serving components in the [`wasi:http/service` world](https://github.com/WebAssembly/WASI/blob/main/proposals/http/wit-0.3.0-draft/worlds.wit) and the new [`wasi:http/middleware` world](https://github.com/WebAssembly/WASI/blob/main/proposals/http/wit-0.3.0-draft/worlds.wit), which both imports and exports the HTTP handler interface, is in development. See [the tracking issue](https://github.com/bytecodealliance/wit-bindgen/issues/1554) for current status. +Wasmtime can also invoke functions exported from a component. +{{#endtab }} +{{#endtabs }} ## Running command components with Wasmtime To run a command component with Wasmtime, execute: @@ -21,8 +37,10 @@ See the [Wasmtime guide](https://docs.wasmtime.dev/) for information on granting ## Running HTTP components with Wasmtime -You can execute components that implement the [HTTP proxy world](https://github.com/WebAssembly/wasi-http/blob/main/wit/proxy.wit) with the `wasmtime serve` subcommand. -[The Wasmtime CLI](https://github.com/bytecodealliance/wasmtime) supports serving these components as of `v14.0.3`. +{{#tabs global="wasi-version" }} +{{#tab name="WASI P2" }} +You can execute components that implement the [HTTP proxy world](https://github.com/WebAssembly/WASI/blob/main/proposals/http/wit/proxy.wit) with the `wasmtime serve` subcommand. +[The Wasmtime CLI](https://github.com/bytecodealliance/wasmtime) supports serving these components as of `v18.0.0`. To run a HTTP component with Wasmtime, execute: ```sh @@ -34,6 +52,13 @@ Try out building and running HTTP components with one of these tutorials 1. [Hello WASI HTTP tutorial](https://github.com/sunfishcode/hello-wasi-http) - build and serve a simple Rust-based HTTP component 2. [HTTP Auth Middleware tutorial](https://github.com/fermyon/http-auth-middleware#running-with-wasmtime) - compose a HTTP authentication middleware component with a business logic component +{{#endtab }} +{{#tab name="WASI P3" }} +Wasmtime 43 and later provide runtime support for the WASI P3 ABI. The `wasmtime serve` subcommand currently targets the [`wasi:http/proxy` world](https://github.com/WebAssembly/WASI/blob/main/proposals/http/wit/proxy.wit) from WASI P2; support for serving components in the WASI P3 [`wasi:http/service`](https://github.com/WebAssembly/WASI/blob/main/proposals/http/wit-0.3.0-draft/worlds.wit) and [`wasi:http/middleware`](https://github.com/WebAssembly/WASI/blob/main/proposals/http/wit-0.3.0-draft/worlds.wit) worlds is in progress. See [the tracking issue](https://github.com/bytecodealliance/wit-bindgen/issues/1554) for current status. + +For an overview of the WASI P3 HTTP interfaces, see [WASI 0.3](https://wasi.dev/releases/wasi-p3) on WASI.dev. +{{#endtab }} +{{#endtabs }} ## Running components with custom exports diff --git a/component-model/theme/tabs-a11y.js b/component-model/theme/tabs-a11y.js new file mode 100644 index 00000000..9c00303a --- /dev/null +++ b/component-model/theme/tabs-a11y.js @@ -0,0 +1,114 @@ +(function () { + 'use strict'; + + // Layer ARIA semantics and keyboard navigation onto the mdbook-tabs + // plugin's markup. The plugin emits plain