Demonstrates interception of an interface export with string parameters and return values.
- Target: greeter (JavaScript) exports
say-helloandsay-goodbyeviamodulewise:examples/greeter - Advice: uppercaser (Rust) uppercases string return values
interface greeter {
say-hello: func(name: string) -> string;
say-goodbye: func(name: string) -> string;
}
world greeter-world {
export greeter;
}./build.sh- Generates the interceptor component from the WIT world using
cargo run(interceptor CLI) - Builds the JavaScript greeter target using
jco componentize - Builds the Rust uppercaser advice using
cargo component - Composes all three into
composed.wasmusingwac plug
./run.shCalls say-hello("world") — the greeter returns "Hello world!", the uppercaser advice transforms it to "HELLO WORLD!".