use super::wrap::Wasip2World;
pub fn emit_world_wit(world: Wasip2World, needs_http: bool) -> String {
let local_name = world.local_name();
let (header_note, body) = match world {
Wasip2World::CliCommand => {
let header =
"// Phase 1.2b1.3 — wasm-gc emits `wasi:cli/run@0.2.4#run` to satisfy this world.";
let body = if needs_http {
" include wasi:cli/command@0.2.4;\n \n // Phase 2 / 0.19 — Http.* effects on `--target wasip2` lower\n // directly to `wasi:http/outgoing-handler.handle` plus the\n // future-incoming-response / incoming-response choreography.\n // WASI 0.3 collapses this into native `future<T>` / `stream<u8>`\n // types and three imports; a `Wasip3World` variant lands when\n // the spec stabilises.\n import wasi:http/outgoing-handler@0.2.4;".to_string()
} else {
" include wasi:cli/command@0.2.4;".to_string()
};
(header, body)
}
Wasip2World::HttpProxy => (
"// Phase 3 / 0.19 — HttpServer.listen on `--target wasip2`.",
" include wasi:http/proxy@0.2.4;".to_string(),
),
};
format!(
"// Generated by `aver compile --target wasip2`.\n\
// Direct WIT lowering: this is the source of truth for the\n\
// component's import / export surface. Component metadata is\n\
// encoded from this same WIT and embedded into the core\n\
// module. See docs/wasip2.md for the contract.\n\
//\n\
{header_note}\n\n\
package aver:user;\n\n\
world {local_name} {{\n\
{body}\n\
}}\n"
)
}