libero/codegen_server

Server-side output generators.

Emits websocket.gleam, the atoms registration .erl file, and the <app>.gleam entry point. These all land in the server package and only compile on the Erlang target.

Values

pub fn write_atoms(
  config config: config.Config,
  discovered discovered: List(walker.DiscoveredType),
) -> Result(Nil, gen_error.GenError)

Generate an Erlang FFI file that pre-registers all constructor atoms discovered by the type graph walker, plus framework atoms used by libero’s wire protocol. Calling ensure/0 from this module creates the atoms in the BEAM atom table so that binary_to_term([safe]) can decode client ETF payloads without rejecting unknown atoms.

pub fn write_if_missing(
  path path: String,
  content content: String,
) -> Result(Nil, gen_error.GenError)

Write content to a file, skipping if the file already exists. Used for scaffolded files that users may customize after generation.

pub fn write_main(
  app_name app_name: String,
  port port: Int,
  server_generated server_generated: String,
  context_module context_module: String,
  js_client_names js_client_names: List(String),
  project_path project_path: String,
) -> Result(Nil, gen_error.GenError)

Generate the server entry point at <project_path>/src/<app_name>.gleam.

pub fn write_websocket(
  server_generated server_generated: String,
  context_module context_module: String,
) -> Result(Nil, gen_error.GenError)

Generate the server websocket handler at server_generated/websocket.gleam. Also writes the Erlang FFI for decoding push messages.

Search Document